Pyinstaller No module named msvc - python

I am using Pyinstaller on Ubuntu to create a binary executable for my Python code. This code has a bunch of files and dependencies. One of them is tensorflow. The executable is getting created correctly but when I try to run it, I get the following error:
Traceback (most recent call last):
File "detection_init.py", line 14, in <module>
import lib.tensorboxDetector as tensorboxDetector
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "lib/tensorboxDetector.py", line 20, in <module>
import tensorflow as tf
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "tensorflow/__init__.py", line 24, in <module>
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "tensorflow/python/__init__.py", line 104, in <module>
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "tensorflow/python/platform/test.py", line 57, in <module>
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "mock/__init__.py", line 2, in <module>
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "mock/mock.py", line 71, in <module>
File "pbr/version.py", line 461, in semantic_version
File "pbr/version.py", line 447, in _get_version_from_pkg_resources
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "pbr/packaging.py", line 32, in <module>
File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
File "setuptools/__init__.py", line 160, in <module>
File "setuptools/monkey.py", line 104, in patch_all
File "setuptools/monkey.py", line 156, in patch_for_msvc_specialized_compiler
File "importlib/__init__.py", line 37, in import_module
ImportError: No module named msvc
How can I resolve this error and run the file correctly?

This problem was solved by using the dev version of Pyinstaller. More details here: https://github.com/pyinstaller/pyinstaller/issues/2824

I added msvc to the hidden imports. I'm still battling imports, but seem to be past this one.
{
a = Analysis(['/Users/Ben/Documents/DeepMeerkat/DeepMeerkat/main.py'],
pathex=['/Users/ben/Documents/DeepMeerkat/DeepMeerkat/'],
binaries=[],
datas=[],
hiddenimports=['setuptools.msvc'],
hookspath=[],
runtime_hooks=[],
excludes=[ 'enchant', 'twisted'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
}

Related

Jupyter Lab not oppening - The process is being used by another process

Hey guys I am trying to open Jupyter Lab and install some packages from the command line and I get the following error, it looks like python is being used by other process.
Traceback (most recent call last):
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 92, in _tempfile
os.write(fd, reader())
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
with self.open('rb') as strm:
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\importlib\_adapters.py", line 54, in open
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\Scripts\jupyter-lab.exe\__main__.py", line 4, in <module>
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\jupyterlab\labapp.py", line 15, in <module>
from jupyterlab_server import (
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\jupyterlab_server\__init__.py", line 5, in <module>
from .app import LabServerApp
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\jupyterlab_server\app.py", line 10, in <module>
from .handlers import LabConfig, add_handlers
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\jupyterlab_server\handlers.py", line 18, in <module>
from .listings_handler import ListingsHandler, fetch_listings
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\jupyterlab_server\listings_handler.py", line 8, in <module>
import requests
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 147, in <module>
from . import packages, utils
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 24, in <module>
from . import certs
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\certs.py", line 14, in <module>
from certifi import where
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\core.py", line 72, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Users\loque\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 98, in _tempfile
_os_remove(raw_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\loque\\AppData\\Local\\Temp\\tmpfsz7k7d8'
How can I fix this?
I try Re-installing python and even installing other versions, not working still :(
I also deleted all the contents in the Temp folders and once i run the code it creates a new temp file that uses the process.

Import issue for falcon.responders in pyinstaller executable

Having an import issue when running the exe (as onefile) created by pyinstaller I added 'falcon.responders' to the list of hidden imports. But still the import error when running the executable. What can be wrong?
Traceback (most recent call last):
File "s2rdf.py", line 62, in <module>
import morph_kgc
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "morph_kgc\__init__.py", line 16, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "morph_kgc\engine.py", line 16, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "morph_kgc\materializer.py", line 14, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "falcon\__init__.py", line 32, in <module>
File "falcon\app.py", line 24, in init falcon.app
ImportError: cannot import name responders
[16196] Failed to execute script 's2rdf' due to unhandled exception!
Snippet from spec file
a = Analysis(
['s2rdf.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=['falcon.app_helpers','falcon.responders'],
hookspath=[],
hooksconfig={},
I had a similar problem, but it was fixed by removing the last generated directories ("build" and "dist") and using this hidden import list:
hiddenimports=['falcon.app_helpers', 'xml.etree', 'falcon.responders', 'xml.etree.ElementTree']

certificate verify failed after deleting .pth files in site-packages

So when I download a package (site-packages), from bitbucket, using this command-line:
pip install --upgrade git+ssh://git#bitbucket.ggf.com:7999/pyt/jira, pip starts to not work.
I tried to debug and find the issue in this output:
Traceback (most recent call last):
File "C:\Programs\Python\lib\importlib\_common.py", line 89, in _tempfile
os.write(fd, reader())
File "C:\Programs\Python\lib\importlib\abc.py", line 371, in read_bytes
with self.open('rb') as strm:
File "C:\Programs\Python\lib\importlib\_adapters.py", line 54, in open
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Programs\Python\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Programs\Python\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Programs\Python\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Programs\Python\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Programs\Python\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Programs\Python\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Programs\Python\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Programs\Python\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Programs\Python\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Programs\Python\lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Programs\Python\lib\site-packages\pip\_vendor\requests\__init__.py", line 135, in <module>
from . import utils
File "C:\Programs\Python\lib\site-packages\pip\_vendor\requests\utils.py", line 27, in <module>
from . import certs
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Programs\Python\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Programs\Python\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Programs\Python\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Programs\Python\lib\site-packages\certifi_win32\wrapt_pip.py", line 35, in apply_patches
import certifi
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Programs\Python\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Programs\Python\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Programs\Python\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Programs\Python\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
File "C:\Programs\Python\lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Programs\Python\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Programs\Python\lib\importlib\_common.py", line 95, in _tempfile
os.remove(raw_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\a77870\\AppData\\Local\\Temp\\3\\tmpjivq2gz5'
I found out that if I removed these two files from site-packages then pip worked again, so for some reason these files make it stuck, but I don't know why?
python-certifi-win32-init.pth
distutils-precedence.pth
Now the problem with doing this is that the package which is installed jira, is an API that needs to connect over SSL, and I guess by deleting these .pth files that this creates some error now?
I get this output running a simple command, and its trying to connect to Jira:
Traceback (most recent call last):
File "C:\Programs\Python\Python3102\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Programs\Python\Python3102\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Programs\Python\Python3102\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "C:\Programs\Python\Python3102\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Programs\Python\Python3102\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Programs\Python\Python3102\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Programs\Python\Python3102\lib\ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "C:\Programs\Python\Python3102\lib\ssl.py", line 1070, in _create
self.do_handshake()
File "C:\Programs\Python\Python3102\lib\ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)
Any ideas on a way where I should delete these files?
By removing python-certifi-win32-init.pth the functionality of the library is effectively lost with doing so.
Andrew Leech, the author of python-certifi-win32, suggests to move on to his other project pip-system-certs . Drop-in replacing the library with pip-system-certs (PyPI link) solved all issues for me.

pyinstaller AttributeError: 'module' object has no attribute 'compat'

I use python2.7.1 and pyinstaller compile a executable exe
pyinstaller compile perfectly but the exe can't run
following is error message
Traceback (most recent call last):
File "main_Preview_v4_4.py", line 12, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\openpyxl\__init__.py", line 6, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\openpyxl\workbook\__init__.py", line 5, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\openpyxl\workbook\workbook.py", line 8, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\openpyxl\worksheet\worksheet.py", line 29, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\openpyxl\cell\__init__.py", line 4, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\openpyxl\cell\cell.py", line 65, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\pandas\__init__.py", line 42, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\pandas\core\api.py", line 26, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
File "c:\users\alphalin\appdata\local\temp\pip-unpacked-wheel-dw4d2a\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\pandas\core\groupby\groupby.py", line 20, in <module>
AttributeError: 'module' object has no attribute 'compat'
[16068] Failed to execute script main_Preview_v4_4
I try to figure out what happen about the error
but google result just lead me to pandas error
I am not using pandas in my code so I am so confuse
any device?
This happens when the icon file (.ico) is collapsed or in incorrect format. If you try it without the --icon argument when running the command in your terminal it might work.
If you try to pass as an argument a different file format, other than .ico you will get errors. Take the image you want to use and convert it to an icon.
If you have to specify and icon then try converting a .png image to .ico. An online converter should do the trick.

Error while running executable created by PyInstaller (python 2.7)

Sorry for asking stupid questions.
I have packaged my python source code using Pyintaller (with Ubuntu 16.04 and pyinstaller 3.3.1). It runs perfectly on my own computers but get different errors. The typical error I got is
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.[1996] Failed to execute script predict".
The detailed error message is shown below. Please help me with this, i don't know how to fix it now. Many thanks!
/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py:687: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
Using TensorFlow backend.
Traceback (most recent call last):
File "predict.py", line 2, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "data_pre.py", line 3, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "csvdata_pre.py", line 1, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/keras/__init__.py", line 3, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/keras/utils/__init__.py", line 6, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/keras/utils/conv_utils.py", line 9, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/keras/backend/__init__.py", line 84, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/tensorflow/__init__.py", line 24, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/tensorflow/python/__init__.py", line 115, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/tensorflow/python/platform/test.py", line 61, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/mock/__init__.py", line 2, in <module>
File "/tmp/pip-install-47BC1A/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "site-packages/mock/mock.py", line 71, in <module>
File "site-packages/pbr/version.py", line 462, in semantic_version
File "site-packages/pbr/version.py", line 449, in _get_version_from_pkg_resources
File "site-packages/pbr/packaging.py", line 812, in get_version
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.
[49902] Failed to execute script predict

Categories