mirror of
https://github.com/brentvollebregt/auto-py-to-exe.git
synced 2026-04-27 12:45:50 +03:00
[GH-ISSUE #104] Module Not Found Error #98
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rcolpo on GitHub (Jun 8, 2020).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/104
I'm trying to make an executable file out of the python code below:
However, I keep receiving the error message
ModuleNotFoundError: No module named '_libsbml'Any ideas on how to solve this?
The line "import _libsbml" was not in my original code. I added it while trying to solve this problem. I also added "_libsbml" on the "--hiddenimport" advanced field, but without results.
@brentvollebregt commented on GitHub (Jun 9, 2020):
What is the "Current Command" that auto-py-to-exe displayed when you packaged your script?
@rcolpo commented on GitHub (Jun 9, 2020):
Current Command:
pyinstaller --noconfirm --onedir --nowindowed "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest.py"Output:
This is the complete error message I got when I try running the newly created executable file:
@brentvollebregt commented on GitHub (Jun 9, 2020):
Are you sure you added
_libsbmlto the hidden import field? That current command you have provided does not have it in there which hints that you didn't add it. (Or that field is broken)@rcolpo commented on GitHub (Jun 9, 2020):
Thank you for your reply.
I also tried the "Current Command"
pyinstaller --noconfirm --onedir --nowindowed --hiddenimport "libsbml" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest3.py"and
pyinstaller --noconfirm --onedir --nowindowed --hiddenimport "_libsbml" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest2.py"but got the same error in both scenarios (same error as in my previous message):
ModuleNotFoundError: No module named '_libsbml'When I try
pyinstaller --noconfirm --onedir --nowindowed --hiddenimport "_libsbml" --hiddenimport "libsbml" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest.py"the "Converting..." step never ends and the executable file is not generated.
@brentvollebregt commented on GitHub (Jun 10, 2020):
If you try to execute
pyinstaller --noconfirm --onedir --nowindowed --hidden-import "_libsbml" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest2.py"in cmd, will it output a working executable in the dist folder or at least give a different error?It's interesting to see that
--hiddenimportis now being used instead of--hidden-import.@rcolpo commented on GitHub (Jun 10, 2020):
Yes, the error changed.
I tried to make an executable file from two different python files:
and
Using the commands
pyinstaller --noconfirm --onedir --nowindowed --hidden-import "_libsbml" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest2.py"and
pyinstaller --noconfirm --onedir --nowindowed "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest2.py"and on the 4 attempts I got the same error:
@brentvollebregt commented on GitHub (Jun 10, 2020):
Are you using auto-py-to-exe to do this? If not, this issue is no longer associated with this tool.
I believe I added a fix for this problem quite a while ago in the tool which is applied automatically.
@rcolpo commented on GitHub (Jun 10, 2020):
I misunderstood your instruction. I'm very sorry.
I tried to create an executable file using the following Current Command:
pyinstaller --noconfirm --onedir --console --hidden-import "_libsbml" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest2.py"Trying to run the file created I got the error
ModuleNotFoundError: No module named 'pkg_resources.py2_warn'The error changed!
Then I changed the Current Command to
pyinstaller --noconfirm --onedir --console --hidden-import "_libsbml" --hidden-import "pkg_resources.py2_warn" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest2.py"And got the error
ModuleNotFoundError: No module named '_libsbml'which is the same error I got when I did not include "_libsbml" on the hidden-import field.
Maybe it could not handle two hidden-import parameters simultaneously?
@brentvollebregt commented on GitHub (Jun 11, 2020):
No need to be sorry; I'm just making sure that auto-py-to-exe is generating the correct command - using PyInstaller manually can help verify this.
From what I see above:
--hidden-import "_libsbml"gave you the errorModuleNotFoundError: No module named 'pkg_resources.py2_warn'--hidden-import "_libsbml" --hidden-import "pkg_resources.py2_warn"you got the errorModuleNotFoundError: No module named '_libsbml'.This seems like a PyInstaller issue. If you select
allby--debugin the advanced tab (or use--debug all), are these modules mentioned in the output when bundling the script?@rcolpo commented on GitHub (Jun 11, 2020):
When I use
--debug "all"the Current Command becomespyinstaller --noconfirm --onedir --console --debug "all" --hidden-import "_libsbml" --hidden-import "pkg_resources.py2_warn" "C:/phd/Eric/SBMLComp-master/Scripts/exePythonTest2.py"and any executable file is generated.
The modules included on the --hidden-import field ("_libsbml" and "pkg_resources.py2_warn") don't have any particular highlight on the output section, which is shown below:
If I have no modules on the
--hidden-importfield, I still have the same error.When I don't include
--debug "all", the executable file is generated but I have the error mentioned before.When I remove the line
import cobra, making my code is simplyprint(1), I have a working executable file.@brentvollebregt commented on GitHub (Jun 12, 2020):
So adding
--debug allto your command make this error occur when packaging the script? That's odd.Typically you need to use
--hidden-importwhen not using theimportkeyword, but looking back at your original script, you were using it, so using--hidden-importprobably won't help - PyInstaller just can't find the import.Maybe if you can locate where the .py associated with the import is, you could add it's location to
--pathsto tell PyInstaller to look there.@rcolpo commented on GitHub (Jun 12, 2020):
Thank you. Adding the module location to
--pathssolved the problem. Thank you very much.