I use one c++ dll in my python code.
When I run my python app on my computer, it works fine but when I copy all to another computer this happen:
Traceback (most recent call last):
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\SoundLog.py", line 9, in <module>
from Auxiliar import *
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar\DataCollection.py", line 4, in <module>
import SoundLogDLL
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar\SoundLogDLL.py", line 4, in <module>
dll = cdll.LoadLibrary(os.environ['PUBLIC'] + "\\SoundLog\\DLLs\\ForPython\\SoundLogC++WrapperDLL.dll")
File "C:\Python26\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 14001] The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail
How can I fix this problem so that my python app work in every computer?
Note:
I only need them to work on windows 7 like mine. And I tested on another win7 computer (both 32bits).
You're using a DLL which depends on a Microsoft Visual C++ runtime which isn't installed on the target computer. You have a few options:
Install or copy the Visual C++ runtime libraries to the target computer. Installation is done by adding merge modules to your installer (if you have one) or by running the redistributable installer (vcredist.exe). The various methods are documented here for VS2005 (other versions will be similar).
If you built the DLL, you can change the project settings to statically link the runtime libraries. See this answer to see how this is done.
Related
Currently trying to build a exe using PyInstaller. The installation goes fine, although when trying to run the exe an exception occurs
Exception ignored in: <function Library.__del__ at 0x000002126637F160>
Traceback (most recent call last):
File "C:\Users\blah\AppData\Local\Programs\Python\Python39\lib\site-packages\pylink\library.py", line 272, in __del__
File "C:\Users\blah\AppData\Local\Programs\Python\Python39\lib\site-packages\pylink\library.py", line 390, in unload
File "C:\Users\blah\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 444, in __getattr__
File "PyInstaller\loader\pyimod04_ctypes.py", line 79, in __init__
pyimod04_ctypes.install.<locals>.PyInstallerImportError: Failed to load dynlib/dll 'kernel32'. Most likely this dynlib/dll was not found when the application was frozen.
I've followed the lead on some other posts and ensured the Visual C++ Redistributables are installed and also included --hidden-import ctypes in the build to no avail.
Building on Windows 10 - Python 3.9 - PyInstaller 5.0.1
Any help would be great!
Taken from the comments on the original answer. Quote stevod:
I ended up finding the problem, our company anti virus wouldn't let the bootloader access the required files, so we had to rebuild the bootloader manually and then it worked!
The same worked also for me.
I receive the following error when running import openslide from inside python terminal
<code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\dev_res\python\python2_713\lib\site-packages\openslide\__init__.py", line 29, in <module>
from openslide import lowlevel
File "C:\dev_res\python\python2_713\lib\site-packages\openslide\lowlevel.py", line 41, in <module>
_lib = cdll.LoadLibrary('libopenslide-0.dll')
File "C:\dev_res\python\python2_713\lib\ctypes\__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "C:\dev_res\python\python2_713\lib\ctypes\__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 127] The specified procedure could not be found
</code>
My OS is Windows 64-bit and I am using Python 2.7.13 (64-bit). I installed the OpenSlide binaries (2016-7-17 64-bit release) and added the corresponding bin folder to my system path. I then installed python-openslide using pip. Please note that this error is different from WindowsError: [Error 126] The specified module could not be found (see question) which occurs when the windows binaries have not been added to the system path.
Same problem occurs when using Python 3.5.3. Interestingly, I tried the same workflow except with the 32-bit versions (python 2.7 32-bit and 32-bit openslide binaries) and I did not receive this error. However, I would prefer to use the 64-bit versions.
Any help would be greatly appreciated. Thanks!
After receiving help from the openslide-python authors on github, I was able to get a working solution.
The problem is that there are multiple dll's in your search path with the same name as those required by openslide. In my case for example, zlib1.dll is not only found in the openslide\bin directory but also in a MATLAB directory, github directory, and an Intel wifi directory. When python asks the operating system to find the required dll, the operating system is going to return the first name-matching instance that it encounters which might not be the openslide\bin one.
A quick fix is to start python from inside the openslide\bin directory. In other words, start a command prompt, navigate to the openslide\bin directory, type "python" and now typing import openslide should work fine. This works because the directory from which python was started is searched first for matching dll's. A more rigorous solution that will prevent you from having to start the terminal every time from inside openslide\bin is to add the following to the beginning of lowlevel.py file (which can be found in Lib\site-packages\openslide directory of your python installation)
os.environ['PATH'] = "path-to-openslide-bin" + ";" + os.environ['PATH']
Note: Replace path-to-openslide-bin with the correct path
Every time you type import openslide lowlevel.py is run which tries to load the appropriate dll's. The above line of code adds the location of the dll's to the beginning of the environment path which ensures that this folder is at the top of the search hierarchy and will therefore be found before the other name-matching instances.
You can view the corresponding issue/user report on github here
I am trying to use Gumbo's python wrapper to parse HTML.
My operating system is Ubuntu 14.04.3 LTS. I am using Python2.7
I have cloned the latest version of Gumbo from github.
I followed the installation steps provided on Github.
The installation of the libraries, both the C library and the python wrapper, appeared to be successful ( No error message, both printed successful messages at the end )
C library final message:
Libraries have been installed in: /usr/local/lib
Python wrapper message:
Installed
/usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg
Processing dependencies for gumbo==0.10.1 Finished processing
dependencies for gumbo==0.10.1
The first problem I encountered was when I tried to open pydoc for gumbo, to better understand the library.
pydoc gumbo produced the following error:
problem in gumbo - <type 'exceptions.OSError'>: /usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/libgumbo.so: cannot open shared object file: No such file or directory
Searching for the message yielded a single result.
It was not of much use to me.
Looking at the dist-packages directory, I noticed that libgumbo.so was not in /usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/ . All other files ( soup-adapter.py, gumboc.py, etc ) where there however.
The installation of the C library placed libgumbo.so ( and some other libraries, like libgumbo.a libgumbo.la, etc ) in /usr/local/lib. So, as a work around, I created a simlink from .../dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/ to /usr/local/lib.
This got pydoc gumbo to work.
I tried to import gumbo and soup-adapter in the interpreter after. I received the following error:
import soup_adapter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "soup_adapter.py", line 26, in <module>
import gumboc
File "gumboc.py", line 44, in <module>
os.path.dirname(__file__), _name_of_lib))
File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libgumbo.so: cannot open shared object file: No such file or directory
I am not sure how to proceed or how exactly to get gumbo to work.
I have a python application primarily dependent on matplotlib, tkinter, numpy and scipy I have been distributing for multiple operating systems. I build these on top of the python.org version of python 2.6. For mac, I have had good success in the past with py2app and pyinstaller to build standalone versions of my application. Recently, however, I have included functions that require patsy, pandas and igraph and have had to move to the mac distributed version of python 2.6 in order to get igraph to work. All works fine in building a py2app version of my software on the Mac for my OS (10.6) but when I run on 10.8 I encountered the following error:
Traceback (most recent call last):
File "UI.pyc", line 603 createHeatMap
File "clustering.pyc", line 31, in <module>
File "mpl_toolkits/__init__.pyc", line 2, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 698, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 701, in Environment
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 96, in get_supported_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 222, in get_build_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/util.py", line 98, in get_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 537, in get_config_vars
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 405, in _init_posix
DistutilsPlatformError: invalid Python installation: unable to open /user/include/python2.6/pyconfig.h (No such file or directory)
This is fixed by saving the file pyconfig.h to the designated location on the destination machine (not present in 10.8 but present in 10.6), which allows my application to work fine. In my py2app pacakge directory, under "Contents/Resources" there is a sym-link to the directory "include" which points to: /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h. If I include the pyconfig.h file as an addition resource in my py2app setup file, it also includes it in the package, but it still is not recognized.
Can anyone suggest a good work around for this that doesn't require me to use the python.org version of python (I've had horrible luck getting igraph to work with this).
Thanks...
This is a known issue in py2app, see https://bitbucket.org/ronaldoussoren/py2app/issue/36/py2app-fails-to-build-a-working-executable. The pyconfig.h file is only present on machines where the developer tools are installed, which is why I haven't noticed the problem myself.
The easiest workaround is probably to replace the pyconfig.h symlink by a copy of the file after creating the app bundle.
I have created a simple program which uses pywin32. I want to deploy it as an executable, so I py2exe'd it. I also didn't want a huge amount of files, so I set bundle_files to 1 (meaning bundle everything together). However, when I attempt running it, I get:
Traceback (most recent call last):
File "pshelper.py", line 4, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "win32.pyc", line 8, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32ui.pyd
In my setup script, I tried doing packages=["win32ui"] and includes=["win32ui"] as options, but that didn't help. How can I get py2exe to include win32ui.pyd?
I don't have this problem if I don't ask it to bundle the files, so I can do that, for now, but I'd like to know how to get it to work properly.
Are you sure that the problem is that win32ui.pyd is not included? The stack trace isn't exactly the same as noted in the wiki, but check this out: http://www.py2exe.org/index.cgi/Py2exeAndWin32ui.
The work-around that has worked best so far is to simply re-implement the pywin32 functions using ctypes. That doesn't require another .pyd or .dll file so the issue is obviated.
Do care to try out PyInstaller? I've used it both on Windows 7 and Ubuntu 10.04 and it worked like magic, even when I compiled to .pyd on Windows.
I've been able to bundle all sorts of applications that I've developed with it.
I have the same problem trying to bundle psutil with py2exe. Here is what I found so far.
Traceback (most recent call last):
File "wx_gui.py", line 43, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\__init__.pyc", line 85, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\_psmswindows.pyc", line 15, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading _psutil_mswindows.pyd
I get this traceback when bundle_files = 3. zipfile may be specified or may be None, I still get the problem.
First, I thought this was a missing dll because of this page:
http://www.py2exe.org/index.cgi/ProblemsToBeFixed
I've copied all the dlls I found in Python27 into the same directory as the executable and added that directory path to os.environ['path']. That didn't worked.
Then I tried to import my package directly from site-packages.
I've replaced the whole sys.path of my compiled executable with my normal sys.path
sys.path = [r'C:\Python27\Lib\idlelib', ...]
I think the .pyd module got imported but Visual c++ threw me this really ugly error message:
Runtime Error!
Program: {path}.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I suggest you try to replace the whole sys.path to see if it is working. If it is, you could always make your single executable write the necessary module into a temp directory and add it to your path. If not, I feel like this problem is going to be hard to solve.