I have this Python script which I want to run on other windows computers without python.So i have tried py2exe and pyinstaller but none of these work as when I try copy the .exe file to an other system and run it but I get an ERROR:
Traceback (most recent call last):
File "client.pyw", line 4, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "gtk\__init__.pyo", line 30, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "gobject\__init__.pyo", line 26, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "glib\__init__.pyo", line 22, in <module>
File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading glib\_glib.pyd
You can try cx_Freeze or include Python installing to program installer (may be a batch script):
msiexec /i /quiet /passive python.msi
When needing to make an executable out of a Python script, I found py2exe (or its GUI brother GUI2Exe to be the most useful tools. There are a few other options.
Related
I'm using py2app to package some Python scripts into an executable on Mac.
I get this error when running it:
...
File "/xxx.app/Contents/Resources/lib/python3.10/paddle/utils/cpp_extension/cpp_extension.py", line 20, in <module>
import setuptools
File "setuptools/__init__.pyc", line 18, in <module>
File "setuptools/dist.pyc", line 39, in <module>
File "setuptools/config.pyc", line 17, in <module>
File "setuptools/extern/__init__.pyc", line 52, in create_module
File "setuptools/extern/__init__.pyc", line 44, in load_module
ImportError: The 'packaging.specifiers' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
2022-12-12 23:35:59.913 xxx[92028:45291215] Launch error
2022-12-12 23:35:59.914 xxx[92028:45291215] Launch error
See the py2app website for debugging launch issues
Currently I have:
paddlepaddle==2.4.0
setuptools==59.8.0
packaging==21.3
How can I fix this?
I am trying to make an executebale out of a .py script I have, in a virtual environment with pyinstaller. however after making my executeable with pyinstaller --onefile myprogram.py when running the resulting myprogram.exe from command prompt, I get this error:
Traceback (most recent call last):
File "myprogram.py", line 4, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\IPython\__init__.py", line 48, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\IPython\core\application.py", line 23, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\traitlets\config\__init__.py", line 6, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\traitlets\config\application.py", line 17, in <module>
ImportError: No module named decorator
decorator is installed in the env I'm working in so that is not the problem (python 2.7.17, pyinstaller 3.5, windows 10, anaconda)
thanks in advance!
I'm running VSCode on windows 10, driver Python 3.8.3 32bits.
When I type on terminal: pipenv shell
I get this error: ImportError: WSAStartup failed: error code 10107
Here's the complete output
Traceback (most recent call last): File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\runpy.py",
line 194, in run_module_as_main
return run_code(code, main_globals, None, File "c:\users\camar\appdata\local\programs\python\python38-32\lib\runpy.py",
line 87, in run_code
exec(code, run_globals) File "C:\Users\camar\AppData\Local\Programs\Python\Python38-32\Scripts\pipenv.exe_main.py",
line 4, in File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv_init.py",
line 22, in
from pipenv.vendor.urllib3.exceptions import DependencyWarning File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3_init.py",
line 11, in
from . import exceptions File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\exceptions.py",
line 3, in
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 199, in load_module
mod = mod._resolve() File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 113, in _resolve
return _import_module(self.mod) File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 82, in _import_module
import(name) File "c:\users\camar\appdata\local\programs\python\python38-32\lib\http\client.py",
line 71, in
import email.parser File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\parser.py",
line 12, in
from email.feedparser import FeedParser, BytesFeedParser File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\feedparser.py",
line 27, in
from email._policybase import compat32 File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email_policybase.py",
line 9, in
from email.utils import _has_surrogates File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\utils.py",
line 29, in
import socket File "c:\users\camar\appdata\local\programs\python\python38-32\lib\socket.py",
line 49, in
import _socket ImportError: WSAStartup failed: error code 10107
I'd like to know how to solve this or, at least, what can I do alternatively to create a virtual enviroment.
Do you want to create a new env?
in that case you can use:
python -m venv myenv
if you want to open an existing environment in a shell you have to run "activate"
which is a file located in the myvenv/scripts folder.
Open you shell, move to the scripts dir and type activate.
You should see a new line in you shell starting with "(venv)"
I've trouble making an CONSOLE app work after packaging.
App flashes once and closes.
in terminal i've put: pyinstaller --onefile --windowed --icon=name.icns Script.py
So far i've tried running the app through terminal to try and get error ( you know like in windows but it failed lol ).
Is there a way to see the reason why it closed?
EDIT:
When i run Executable within app i get this error:
File "Script.py", line 14, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages/requests/__init__.py", line 43, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages/urllib3/__init__.py", line 8, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages/urllib3/connectionpool.py", line 28, in <module>
File "site-packages/urllib3/packages/six.py", line 92, in __get__
File "site-packages/urllib3/packages/six.py", line 115, in _resolve
File "site-packages/urllib3/packages/six.py", line 82, in _import_module
ImportError: No module named 'queue'
I have nothing about "queue" in code and .py works great and gives no import error.
Thank you.
Seems like there's an error importing one of your modules, perhaps its dependencies aren't being detected correctly.
You can try to explicitly add a module via the command line by including --hidden-import=queue, you might have to do this for more modules that haven't been detected. More discussion in this question.
I am working with QGIS Pisa in Windows environment.I wanted to upgrade the scipy module of Python present inside OSGeo4W. For that I installed pip from the OSGeo4W windows command shell. I closed the command shell after installation and reopened it.
When I give the pip command inside OSFGeo4W windows command shell, it is referring to pip module installed at the system level and hence I am getting an error. I don't know how to correct this thing. Here is my error stack trace:
Traceback (most recent call last):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals
File "C:\Python27_32Bit\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\__init__.py", line 13, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\utils\__init__.py", line 26, in <module>
from pip._vendor import pkg_resources
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 76, in <module>
__import__('pip._vendor.packaging.specifiers')
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 275, in <module>
class Specifier(_IndividualSpecifier):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 374, in Specifier
re.VERBOSE | re.IGNORECASE,
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 190, in compile return _compile(pattern, flags)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 242, in _compile raise error, v # invalid expression
sre_constants.error: nothing to repeat
As you can see on the stacktrace, 3rd line from top, the code refers to pip module of python installed at the system level instead of pip module installed inside the QGIS Pisa. How can I correctly run this ?