The app is working fine on my development win8 environment, but when it is packaged with py2exe and run on the production machine it throw the exception:
"The procedure entry point RtlIdnToAscii could not be located in the dynamic link library ntdll.dll"
The detail content of the log file is
Traceback (most recent call last):
File "DataviewerBackupRestorer.py", line 6, in <module>
File "RestorController.pyc", line 7, in <module>
File "psutil\__init__.pyc", line 136, in <module>
File "psutil\_psmswindows.pyc", line 14, in <module>
File "_psutil_mswindows.pyc", line 12, in <module>
File "_psutil_mswindows.pyc", line 10, in __load
ImportError: DLL load failed: The specified procedure could not be found.
It seems that a dll required by psutil is missing during the package process. I have tried to add the py2exe options with
py2exe_options = {"py2exe":{"includes":['decimal', '_mssql', 'uuid', 'psutil', '_psutil_mswindows']}}
But it is not working. Any ideas? Thanks in advance!
The solution is to remove System DLLs from the project directory. When I added psutil to my application py2exe added a lot of system DLLs to my project. It worked correctly on my and some other computers, but failed on another one. Removing from the project the .dll files that were available in C:\Windows\System32 solved the issue.
Finally in my case the solution was to add:
'dll_excludes': [ "IPHLPAPI.DLL", "NSI.dll", "WINNSI.DLL", "WTSAPI32.dll"]
into the py2exe options in setup.py file.
Related
I have a project which I am packaging with cx_freeze. When I try to run the resulting exe I get an ImportError: DLL load failed: The specified module could not be found.
Here is my setup.py:
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(build_exe='liquidation', packages=['scipy', 'numpy'], excludes=['scipy.spatial.cKDTree'],
includes=['scipy', 'numpy', 'numpy.core._methods', 'scipy.sparse.csgraph._validation',
'numpy.lib.format', 'numpy.linalg._umath_linalg', 'scipy.sparse._csparsetools',
'scipy.sparse.linalg.isolve._iterative', 'scipy.sparse.linalg.eigen.arpack._arpack',
'scipy.special._ufuncs_cxx', 'scipy.special.specfun', 'scipy.integrate._odepack',
'scipy.integrate._quadpack', 'scipy.integrate.vode', 'scipy.integrate._dop',
'scipy.integrate.lsoda', 'scipy.optimize._minpack', 'scipy.optimize._zeros',
'scipy.spatial', 'scipy.spatial.ckdtree', 'scipy.spatial.kdtree',
'scipy._distributor_init', 'numpy.core._multiarray_umath'])
base = 'Console'
executables = [
Executable('liquidation.py', base=base, targetName='liquidation.exe')
]
setup(name='liquidation',
version='2.0',
description='Program to run and test Liquidation algorithms',
options=dict(build_exe=buildOptions),
executables=executables)
When I run python setup.py build_exe it seems to complete successfully, but when I run the exe I get the following output:
Traceback (most recent call last):
File "C:\Users\tamar\PycharmProjects\liquidation\venv\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
from . import multiarray
File "C:\Users\tamar\PycharmProjects\liquidation\venv\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
from . import overrides
File "C:\Users\tamar\PycharmProjects\liquidation\venv\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\tamar\PycharmProjects\liquidation\venv\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 40, in run
module.run()
File "C:\Users\tamar\PycharmProjects\liquidation\venv\lib\site-packages\cx_Freeze\initscripts\Console.py", line 37, in run
exec(code, {'__name__': '__main__'})
File "liquidation.py", line 64, in <module>
from io_tools.stock_wrapper import StockWrapper
File "C:\Users\tamar\PycharmProjects\liquidation\io_tools\stock_wrapper.py", line 4, in <module>
from io_tools.io_helper import *
File "C:\Users\tamar\PycharmProjects\liquidation\io_tools\io_helper.py", line 7, in <module>
from numpy import float_
File "C:\Users\tamar\PycharmProjects\liquidation\venv\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Users\tamar\PycharmProjects\liquidation\venv\lib\site-packages\numpy\core\__init__.py", line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\Users\tamar\PycharmProjects\liquidation\liquidation\liquidation.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.3" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
I understand that I need to point cx_freeze to the missing DLL's (either by adding them to buildOptions.include_files or by actually copying the DLL's to the build folder) but I am at a loss as to how to know which DLL's I am missing. numpy.core._multiarray_umath is in the build folder so I don't know what it could be.
I believe I am using the latest versions of numpy (1.18.3), scipy (1.4.1) and cx-freeze (6.1). Any help would be much appreciated!
Update: I used Dependency Walker to try and see what I am missing and it listed a file by the name of LIBOPENBLAS.SVHFG5YE3RK3Z27NVFUDAPL2O3W6IMXW.GFORTRAN-WIN32.DLL which cannot be found. All of the other dependencies have been copied into the build so it makes sense that this would be the missing one. Does anyone know where I can find this file?
I am trying to build executable file of my project(Python 2.7.5) but getting this below error when trying to run the executable.
ERROR \ProjectPython\library.zip\distutils\__init__.py:14: UserWarning: The virtualenv
distutils package at %s appears to be in the same location as the system distutils?
Traceback (most recent call last):
File "main.py", line 130, in <module>
...
File "pandas\compat\__init__.pyo", line 32,in <module>
File "zipextimporter.pyo", line 82, in load_module
File "distutils\__init__.pyo", line 25, in <module>
ERROR ImportError: cannot import name dist
After searching for solutions to this issue, I got to know that this must be because of distutils in virtualenv is different from whats in Python installation Lib directory. So, I have been trying to exclude/remove distutils in virtualenv and add distutils package of my origin interpreter during executable build.
That exact solution exists for cxfreeze, but couldn't find alternate solution for py2exe. My setup.py options looks something like
distutils.core.setup(
options = {"py2exe": {
"compressed": 1,
"optimize": 1,
"bundle_files": 1,
"packages": ['psycopg2', 'lxml', 'sqlalchemy', 'openpyxl', 'pandas', 'numpy']
}}
Any help on this is much appreciated. Thanks !
Given the information you've shared, it seems that you might be going the wrong direction with excluding distutils. The error (warning) is stating that distutils package at %s appears to be in the same location as the system distutils.
Try creating a fresh virtual environment with the needed libraries and building again.
I wanted to use pyueye module to manipulate my IDS camera. I've installed latest drivers from manufacturer's website and I can manage the camera by using uEye Cockpit appliaction. I wanted to write some python script to use with camera, but i can't even import pyueye module.
My code:
import ctypes
from pyueye import ueye
print(ueye.__version__)
Error info:
C:\Python\python.exe C:/Users/Karol/PycharmProjects/ids_camera/ids_test.py
Traceback (most recent call last):
File "C:\Python\lib\site-packages\pyueye\dll.py", line 165, in load_dll
dll = DLL(libinfo, libnames, os.getenv(envname))
File "C:\Python\lib\site-packages\pyueye\dll.py", line 96, in __init__
raise RuntimeError("could not find any library for {} ({})".format(libinfo,
dllmsg))
RuntimeError: could not find any library for ueye_api (DLL_PATH: unset)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
\File "C:/Users/Karol/PycharmProjects/ids_camera/ids_test.py", line 2, in
<module>
from pyueye import ueye
File "C:\Python\lib\site-packages\pyueye\__init__.py", line 55, in <module>
from . import ueye
File "C:\Python\lib\site-packages\pyueye\ueye.py", line 54, in <module>
get_dll_file, _bind = load_dll("ueye_api", ["ueye_api_64", "ueye_api"],
"PYUEYE_DLL_PATH")
File "C:\Python\lib\site-packages\pyueye\dll.py", line 167, in load_dll
raise ImportError(exc)
ImportError: could not find any library for ueye_api (DLL_PATH: unset)
Process finished with exit code 1
I have installed that module via pip, my OS is Win 7 x64, my python interpreter is 3.6, also *.dll files associated with ueye are installed in C:\Windows... folder. I also copied ueye_api.dll and ueye_tools.dll files to pyueye directory, but it didn't help.
I tried adding ueye_api_64.dll from C:\Program Files\IDS\uEye\USB driver package to my pyueye folder. I also added this location to the system variable's PATH and this solved the problem for me.
Try the following things:
Restart your computer after the installation.
Make sure the DLL is in your C:\Windows\System32 directory.
Set PYUEYE_DLL_PATH to the directory of where the DLL is located.
When nothing of that helps please contact the IDS support.
I only put the DLL in the C:\Windows\System32 directory and it works right away. No restart, no addition to PATH.
Cheers.
(Python3)
I wrote a program it works fine without any errors when I run it from the python interpreter, I then used py2exe to turn it in to an .exe but when I run it it does'nt work anymore... I get this error:
Traceback (most recent call last):
File "pass.py", line 1, in <module>
File "dropbox\__init__.pyc", line 3, in <module>
File "dropbox\client.pyc", line 22, in <module>
File "dropbox\rest.pyc", line 26, in <module>
File "pkg_resources.pyc", line 950, in resource_filename
File "pkg_resources.pyc", line 1638, in get_resource_filename
NotImplementedError: resource_filename() only supported for .egg, not .zip
Am I supposed to do something when using py2exe when I have downloaded modules imported into the program?
these are the modules imported :
import dropbox
import os
import getpass
from time import sleep
please help !
I fixed this problem using the solution found here
basically you modify ~line 26 in rest.py found in the dropbox library
to this:
try:
TRUSTED_CERT_FILE = pkg_resources.resource_filename(__name__, 'trusted-certs.crt')
except:
# if current module is frozen, use library.zip path for trusted-certs.crt path
# trusted-certs.crt must exist in same directory as library.zip
if hasattr(sys,'frozen'):
resource_name = sys.prefix
resource_name.strip('/')
resource_name += '/trusted-certs.crt'
TRUSTED_CERT_FILE = resource_name
else:
raise
and then place the trusted-certs.crt file also found in the dropbox library in the same folder as your executable
I am trying to build an exe file using py2exe. The script is to create some word clouds using pytagcloud.
The issue is that py2exe doesn't include the entire pytagcloud package because of which the exe doesn't work. What I mean by this is that in Lib\site-packages, pytagcloud contains two folders fonts and lang. However, after building the exe when I check the build, the fonts folder is missing. The exe itself gives this error:
Traceback (most recent call last):
File "wordcloud.py", line 6, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "pytagcloud\__init__.pyc", line 25, in <module>
IOError: [Errno 2] No such file or directory: 'C:\\Users\\...\\dist\\wordcloud.exe\\pytagcloud\\fonts\\fonts.json'
I've been stuck at this for over 8 hours! I'm totally frustrated now! I would highly appreciate any help!
I am using Win 7, Python 2.7.3 and Pytagcloud 0.3.5