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()
Related
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 have seen many threads that have a high level of ambiguity and go off on tangents from the original question, often assuming much about the authors ability, so I am hoping that if I am direct and concise with my information, I will get an answer that is in line with the requirement. I know that the serious programmers will have seen this many times, in many formats, so please just bear with me as this is doing my head in. Please do not just post a link to some other answer as I rarely find that helps with my current issue.
I am not a hardcore programmer, I find the compiling, sourceball, tar, gz all nonsense to be honest and am looking for the easiest way to install sip for python on my machine. I have installed various versions of mingw32, mingw64 to the point that I don't know which one is best to use. I am assuming that the one here: C:\Program Files\mingw-w64 is the one, considering I am using 64 bit, but do the others I have installed impact on this?
I also installed versions of mysys:
C:\msys\1.0,
C:\msys64, but I still m unclear what and why etc, despite trying to read the docs that came with them.
I have windows 10, 64 bit professional edition.
I have python 2.7
I have installs of mingw, 32 bit and 64 bit in various locations, due mostly to not fully understanding what exactly it was or where it should go. I found zips of it and exes, so I got a bit confused.
I downloaded the sip package and unpacked it to here: C:\Python27\Lib\site-packages\sip-4.19.3 and it has the configure.py file in it. So far, so good.
I used a CMD window, changed directory to: C:\Python27\Lib\site-packages\sip-4.19.3 and then used the command: python configure.py to create the Makefile file which is what I believe is supposed to happen.
I then opened the mingw64 shell, changed directory to the above sip folder and typed: python configure.py again, just to be sure I would get a response and create the files again, probably should not have done so, but hey ho, at this point, I am quite frustrated with it and trying to do anything with what I have, which I know is poor practice. (see image 1.)
image 1: configure.py executed
From what I have read, I should use the make function that comes with Mingw64, but I tried the following, which also includes the configure.py code, but nothing seems to work when trying to use the Makefile file that was created via the configure.py process.
c:\Python27>cd ./Lib/site-packages/sip-4.19.3
c:\Python27\Lib\site-packages\sip-4.19.3> python configure.py
This is SIP 4.19.3 for Python 2.7.13 on win32.
The SIP code generator will be installed in C:\Python27.
The sip module will be installed in C:\Python27\Lib\site-packages.
The sip.pyi stub file will be installed in C:\Python27\Lib\site-packages.
The sip.h header file will be installed in C:\Python27\include.
The default directory to install .sip files in is C:\Python27\sip.
Creating siplib\sip.h...
Creating siplib\siplib.c...
Creating siplib\siplib.sbf...
Creating sipconfig.py...
Creating top level Makefile...
Creating sip code generator Makefile...
Creating sip module Makefile...
c:\Python27\Lib\site-packages\sip-4.19.3> Makefile
'Makefile' is not recognized as an internal or external command,
operable program or batch file.
c:\Python27\Lib\site-packages\sip-4.19.3> make Makefile
make: Nothing to be done for `Makefile'.
c:\Python27\Lib\site-packages\sip-4.19.3> Makefile Makefile
'Makefile' is not recognized as an internal or external command,
operable program or batch file.
c:\Python27\Lib\site-packages\sip-4.19.3>
So now I am at an impasse. I have the locations of my mingw versions and the msys in my path environment variable and I have done just about everything I have looked at on the web. I realise that its an order of things, but I really wish there were just executables for these modules and supporting tools as this compiling is a ball ache.I tried opening a python shell and importing sip.
>>> import os, sys
>>> import sip
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import sip
ImportError: No module named sip
>>> import sipconfig
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import sipconfig
ImportError: No module named sipconfig
>>> from sip import sip
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from sip import sip
ImportError: No module named sip
>>> from sipconfig impport sip
SyntaxError: invalid syntax
>>> from sip import *
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
from sip import *
ImportError: No module named sip
So, if anyone has read through this and has a definitive answer as to what I am doing wrong, I would appreciate it.
make/nmake or make/nmake install cant be done from cmd and python path; instead using mingw or visual studio tools.
In windows search for prompt or Visual studio tools to open VS Command promt and from there cd--> sip file location (before this run configure.py present in sip folder)
Now run the commands nmake and then nmake install
I want to install the python package CyIpopt (https://github.com/matthias-k/cyipopt) on windows 10 and python version 3.5.2. For the binary I am using http://www.coin-or.org/Binaries/Ipopt/Ipopt-3.10.1-Win32-Win64-dll.7z (which I unpacked). The github page gives install instructions. At one point it says:
Download the source files of cyipopt and update setup.py to point to the header files and binaries of the Ipopt package, if LD_LIBRARY_PATH and pkg_config are not setup to find ipopt on their own.
I downloaded the source files from github and edited the setup.py file by altering lines 33-36 to :
IPOPT_ICLUDE_DIRS=['D:\...\Ipopt-3.10.1-Win32-Win64-dll\include\coin', np.get_include()]
IPOPT_LIBS=['IpOptFSS','IpOpt-vc10','IpOpt-vc8']
IPOPT_LIB_DIRS=['D:\...\Ipopt-3.10.1-Win32-Win64-dll\lib\\x64\Release MKL']
IPOPT_DLL=['IpOptFSS.dll','IpOpt-vc10.dll','IpOpt-vc8.dll']
The dots represent the path to these folders on my computer. Now when I run python setup.py install, it run succesfuly. However when I then run python and import ipopt I get the following error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Linthorst\Miniconda3\lib\site-packages\ipopt-0.1.6-py3.5-win-amd64.egg\ipopt__init__.py", line 40, in
from cyipopt import *
ImportError: No module named 'cyipopt'
I suspect I altered the setup.py file incorrectly (since I made an educated guess). I am confused that it installed but doesn't work. Can anybody help me solve this error? Many thanks in advance
I want to use Blender 2.72b with OpenCV, so I had to build it for Python3 (I have 3.4.2 installed since Blender is using that too). I'm working on Win7 64bit, so I used a 64bit version of Python and NumPy (Blender too of course). For OpenCV I used 3.0.0-beta.
For building I used CMake 2.8 and Visual Studio 2010 Professional (since I have a student-license > Visual Studio 10 Win64 in CMake).
I followed these instructions (lower ones), modified for python3.
These are my folders:
Target build-folder for CMake (OpenCV.sln executed and build in here too of course):
C:\Users\Gunnar\Desktop\build\
OpenCV-source-folder:
C:\Users\Gunnar\Downloads\opencv\sources\
Python installed here:
C:\Python34\
The build went fine, I adjusted the following before generating with CMake (python2 left blank):
PYTHON3_EXECUTABLE -> C:/Python34/python.exe
PYTHON3_INCLUDE_DIR -> C:/Python34/include
PYTHON3_LIBRARY -> C:/Python34/libs/python34.lib
PYTHON3_NUMPY_INCLUDE_DIRS -> C:/Python34/Lib/site-packages/numpy/core/include
PYTHON3_PACKAGES_PATH -> C:/Python34/Lib/site-packages
BUILD_opencv_python3 -> true
The build-folder has a cv2.pyd at
C:\Users\Gunnar\Desktop\build\lib\Release\
The cv2.pyd got copied to
C:\Python34\Lib\site-packages\
automatically and I copied it to
M:\Programme\blender-2.72b-windows64\2.72\python\lib\site-packages\
If I now open the python IDLE, I get the following error (same in Blender of course):
>>> import cv2
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
(in english: DLL load failed: Module not found.)
I'm assuming that I'm missing environment variables (from what I've found googling for it).
Looking into them I have no corresponding entry for PATH and no PYTHONPATH.
My problem now is that I don't know what I need to set there. I never really had to change something in there and I don't know what exactly is needed.
If more information are needed let me know.
EDIT:
I got i working now. I'm not quite sure, which one it did in the end, but I first used
cmd > setx -m OPENCV_DIR C:\Users\Gunnar\Desktop\build
and than edited the PATH-variable with these:
C:\Users\Gunnar\Desktop\build;
C:\Users\Gunnar\Desktop\build\lib\Release;
C:\Users\Gunnar\Desktop\build\x64\Release;
C:\Users\Gunnar\Desktop\build\bin\Release
And right now it works even though I removed all of them...
I'm running Debian 6.0.6
I've downloaded latest version of libtorrent-rasterbar from here: http://code.google.com/p/libtorrent/downloads/detail?name=libtorrent-rasterbar-0.16.6.tar.gz&can=2 and installed it:
./configure --enable-python-binding
make
make install
cd bindings/python
python setup.py build
python setup.py install
now I want to test whether the library works:
>>> import libtorrent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libtorrent-rasterbar.so.7: cannot open shared object file: No such file or directory
The packaged version of libtorrent from the distributive's repository had some funny behaviour (complaining on boost dependences), so I've decided to upgrade. The same situation is on both of my debian boxes, yet ubuntu box is fine.
old error message from my debian box:
File "ar.py", line 15, in create
s.start_dht()
Boost.Python.ArgumentError: Python argument types in
session.start_dht(session)
did not match C++ signature:
start_dht(libtorrent::session {lvalue}, libtorrent::entry)
Search for the shared object file and add it to your path.
sudo updatedb
locate libtorrent-rasterbar.so.7
This should output /<path_to_directory>/libtorrent-rasterbar.so.7
Add this to your ~/.profile or temporarily tell Python where to look:
export LD_LIBRARY_PATH=/<path_to_directory>/
See more detailed installation instructions here.