I want to build M2Crypto for Windows x64 to be used in python 2.7 in Windows x64.
I downloaded the library package named: "M2CryptoWin64-master" from: https://github.com/martinpaljak/M2Crypto
Then, I followed these steps from enter link description here:
In setup.py:
replace self.openssl = 'C:\pkg' by self.openssl =
'C:\grr-build\openssl' replace name = 'M2Crypto.__m2crypto' , by name
= '__m2crypto' Build:
set PATH=%PATH%;C:\grr-build\swigwin-2.0.9 C:\Python27\python.exe
setup.py build C:\Python27\python.exe setup.py install To get M2Crypto
to work for PyInstaller:
Rename C:\Python27\lib\site-packages\M2Crypto-0.21.1-py2.7-win32.egg
to C:\Python27\lib\site-packages\M2Crypto-0.21.1-py2.7-win32.egg.zip
extract M2Crypto-0.21.1-py2.7-win32.egg.zip into
C:\Python27\lib\site-packages\ without a
M2Crypto-0.21.1-py2.7-win32.egg sub directory remove
M2Crypto-0.21.1-py2.7-win32.egg.zip
When I test the library by going to Python.exe and type:
>>> import M2Crypto
I get this message:
Traceback (most recent call last): File "", line 1, in
File
"C:\Python27\lib\site-packages\m2crypto-0.22.3-py2.7-win-amd64.egg\M2Cryp
to__init__.py", line 22, in
import __m2crypto ImportError: DLL load failed: The operating system cannot run %1.
Can you please help me figure out how to solve the issue?
EDIT:
I also did the following to get M2Crypto to work for PyInstaller:
Rename C:\Python27\lib\site-packages\M2Crypto-0.21.1-py2.7-win32.egg to
C:\Python27\lib\site-packages\M2Crypto-0.21.1-py2.7-win32.egg.zip
extract M2Crypto-0.21.1-py2.7-win32.egg.zip into
C:\Python27\lib\site-packages\ without a
M2Crypto-0.21.1-py2.7-win32.egg sub directory remove
M2Crypto-0.21.1-py2.7-win32.egg.zip
Related
I'm building a c++ python extension. So far, I created versions for Linux and Windows. Currently, I'm struggling with the MacOS version. CMake produces 2 libraries:
43898860 Aug 29 13:40 libslide_io.dylib
214876 Aug 29 13:40 slideio.cpython-35m-darwin.so
I pack them to a whl file. After installation with pip, when I try to import the package, I'm getting the following error:
(sld-35)dist % python -c "import slideio"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: dlopen(/Users/.../opt/anaconda3/envs/sld-35/lib/python3.5/site-packages/slideio.cpython-35m-darwin.so, 2): Library not loaded: libslide_io.dylib
Referenced from: /Users/.../opt/anaconda3/envs/sld-35/lib/python3.5/site-packages/slideio.cpython-35m-darwin.so
Reason: image not found
Both libraries are correctly placed to the python environment directory:
/Users/.../opt/anaconda3/envs/sld-35/lib/python3.5/site-packages/
Moreover, if I unzip the whl file and import the package from the current directory, it works.
I suspect that it is something with rpath settings in my cmake files, but cannot find the correct solution. All my attempts are failed.
I would appreciate any help.
If somebody is interested. I solved the problem by adding a post-build with the execution of install_name utility with the #loader_path parameter. The command instructs the system looking for the library at the loader (in my case - the python package) folder.
if (APPLE)
add_custom_command(TARGET ${BINDLIB_NAME}
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change libslide_io.dylib #loader_path/libslide_io.dylib
$<TARGET_FILE:${BINDLIB_NAME}>)
endif()
I am trying to create an executable file (exe) for a Python script that I written in PyCharm.
When I run the script from the PyCharm is working fine but when I try to run it as an individual .py or try to run the exe I am getting an error.
The issue I believe is with the "from infi.devicemanager import DeviceManager" library.
from infi.devicemanager import DeviceManager # Used for the retrievement of Device manager information
dm = DeviceManager()
dm.root.rescan()
devs = dm.all_devices # Get all the devices to a list called devs
for d in devs:
print (d.description)
I get following error:
PS C:\Python> python.exe .\tests.py
Traceback (most recent call last):
File ".\tests.py", line 1, in <module>
import infi.devicemanager # Used for the retrievement of Device manager information
ModuleNotFoundError: No module named 'infi'
PS C:\Python> pyinstaller -F .\tests.py
PS C:\Python\dist> .\tests.exe
Traceback (most recent call last):
File "tests.py", line 1, in <module>
ModuleNotFoundError: No module named 'infi'
[15072] Failed to execute script tests
Is there a way to include this library to the exe file so anyone without python can run this script?
I am open to suggestions.
Thank you in advance!
=== UPDATE ===
Full script can be found here
https://github.com/elessargr/k9-serial
My answer assumes that the interpreter that has infi.devicemanager is C:\Python\venv\Scripts\python.exe as stated by OP in the comments
So there is virtual environment named venv. You need to activate the virtual environment and install PyInstaller in it.
C:\Python>venv\Scripts\activate
(venv)C:\Python>
Note (venv) in front of your shell - that means virtual environment venv is activated
Now install PyInstaller
(venv)C:\Python>pip install pyinstaller
-- here it will install pyinstaller --
now you can test that both pyinstaller and infi.devicemanager are installed in venv
(venv)C:\Python>pip list
it should list both packages among some others. now
(venv)C:\Python>pyinstaller -F C:\Python\tests.py --hidden-import=infi.devicemanager
--here it will create the exe --
if I was right it should work now
EDIT: It looks like infi is using __import__(pkg_resources), so the command should be
(venv)C:\Python>pyinstaller -F C:\Python\tests.py --hidden-import=infi.devicemanager --hiden-import=pkg_resources
I get an error:
Traceback (most recent call last):
File "C:/Users/me/PycharmProjects/cis-service/project/project.py", line 12, > in
from PIL import Image
File "C:\Users\me\PycharmProjects\project\venv\lib\site-packages\PIL\Image.py", line 64, in
from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
What I've tried so far was solution suggested in ImportError: DLL load failed: %1 is not a valid Win32 application for _imaging module. The only wheel that I could install was 32bit:
(venv) C:\Users\me\PycharmProjects\project>pip install Pillow-5.3.0-cp27-cp27m-win32.whl
Processing pillow-5.3.0-cp27-cp27m-win32.whl
Installing collected packages: Pillow
Successfully installed Pillow-5.3.0
My Python version:
Python 2.7.13 (default, Jan 16 2017, 09:15:04) [MSC v.1500 32 bit (Intel)] on win32).
But it didn't help at all. One thing to notice is that I've tried to install python 2.7.15 on other venv and it worked fine. But with 2.7.13 that my project uses it doesn't work. One thing to notice that this python is specific and highly modified. So I can't just reinstall it. What could be other possible solutions for this problem or how could I trace the problem to get more information? Maybe Python folder it self is missing something (like some sort of DDL)?
EDIT:
I tried to install Pillow using easy install directly to python (I made a copy of python with all env. variables instead of creating virtual env. just to see how it reacts). Still no results. Error is bit different tho:
Traceback (most recent call last):
"C:/Users/me/PycharmProjects/asd78798/image2tif/image2tif.py", line 12, in
from PIL import Image
File "C:\python27_testing\Python27\lib\site-packages\pillow-5.3.0-py2.7-win32.egg\PIL\Image.py", line 64, in
File "C:\python27_testing\Python27\lib\site-packages\pillow-5.3.0-py2.7-win32.egg\PIL_imaging.py", line 7, in
File "C:\python27_testing\Python27\lib\site-packages\pillow-5.3.0-py2.7-win32.egg\PIL_imaging.py", line 6, in bootstrap
ImportError: DLL load failed: The specified module could not be found.
EDIT-2:
Found program http://www.dependencywalker.com/ which I used to scan _imaging.pyd file. Possibly found which DDL's might be missing: MSVCR90.DLL, PYTHON27.DLL. I Found and downloaded MSVCR90.DLL from https://www.dll-files.com/. Still not sure what to do with it.
The solution was to download new python 2.7.13, then copy python27.dll, msvcr90.dll, Microsoft.VC90.CRT.manifest files from Python27 folder to my Python27 folder and Pillow started to work. http://www.dependencywalker.com/ was very handy here. When I walked through _imaging.pyd dependency file it showed that these two dll files were missing.
I am trying to install imgseek- the server version (http://www.imgseek.net/) to do image analysis.I am able to install all the dependencies successfully using:
sudo port install swig
sudo port install swig-python
sudo easy_install twisted
sudo port install imagemagick
sudo easy_install epydoc
Then I download isk-daemon from the downloads(isk-daemon-0.9.3.tar.gz) and build and install it. Everything runs succesfully.
But when I run iskdaemon.py from the command prompt, i get the following error:
sk-daemon : WARNING | no config file (isk-daemon.conf) found. Looked at local dir, home user dir and /etc/iskdaemon. Using defaults for everything.
root : ERROR Unable to load the C++ extension "_imgdb.so(pyd)" module.
root : ERROR See http://www.imgseek.net/isk-daemon/documents-1/compiling
Traceback (most recent call last):
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/ImageDB.py", line 35, in
import imgdb
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/imgdb.py", line 28, in
_imgdb = swig_import_helper()
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/imgdb.py", line 20, in swig_import_helper
import _imgdb
ImportError: dlopen(/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/_imgdb.so, 2): Symbol not found: __ZNSs4_Rep20_S_empty_rep_storageE
Referenced from: /Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/_imgdb.so
Expected in: dynamic lookup
Please help!
I had the same problem when I was trying to install iskdaemon on my Mac (osx yosemite).
The problem in my case was that when I was building it, the c++ compiler threw two errors on using min function in imgdb.cpp
The error was because the types of the variables in the min function were not the same. Consequently the build failed and the imgdb module wasn't produced.
I fixed it by adding a simple typecast to the variables passed to the min function:
I changed: min(sz, numres) to min(sz, (long int)numres) on line 1003,
and min((V.size()/2), numres) to min((int)(V.size()/2), numres) on line 1327
I built again and it is working now.
Check if you get any errors when you build, maybe you are facing the same issue.
I'm following the pycairo installation instructions here :
http://www.cs.rhul.ac.uk/home/tamas/development/igraph/tutorial/install.html
to install pycairo for use with igraph.
However, even after running the installer and unzipping/copying all DLL's into the site-packages cairo directory according to the instructions, I still get the following error:
>>> import cairo
Traceback (most recent call last):
File "", line 1, in
File "c:\Python26\lib\site-packages\cairo__init__.py", line 1, in
from _cairo import *
ImportError: DLL load failed: The specified module could not be found.
>>>
I am running python 2.6.6 under Windows 7.
Any ideas?
Open _cairo.pyd in Dependency Walker and figure out what it's missing.
I kinda solved the problem installing the Gtk-Bundle for Windows, wich had the third party dll dependencies.
(I did a dirty solution by pasting the dlls directly into c:/Python27/lib/dist-packages/cairo, because I am not used to Windows anymore and don't know for sure what is the expected place for the dlls to go.)
But my scripts started to work at last.