I successfully installed dlib for python, following instructions here. However, when I try to import the library I get this message:
>>> import dlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/dlib/__init__.py", line 1, in <module>
from .dlib import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/dlib/dlib.so, 2): Library not loaded: #rpath/libpng16.16.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/dlib/dlib.so
Reason: image not found
I previously had(and uninstalled) anaconda and had the same issue in python 3.6. Looking at similar questions and responses it sounds like I would have to use install_name_tool command. However I do not know what the new path would be. I do not quite understand why this is necessary either. From what I know, the path that was referenced should have been fine. Why will dlib not import and what can I do to make it import successfully? Let me know. Thanks
I don't know if I would call this a solution, since I still have issues, but what I did was: install_name_tool -change #rpath/libpng16.16.dylib "/Library/Python/2.7/site-packages/dlib/dlib.so" /usr/local/lib/python2.7/site-packages/dlib/dlib.so
Although there was an additional problem with my installation, this fixed the problem at hand. I had dlib in my default python library rather than with a path similar to one in my virtual machine. So I changed the path to fit my VM and all my other installation packages(e.g boost and cmake)
Related
I was following along a tutorial where they used the SpeechRecognition module, but when I made it to the first test it returns C:\Users\USER\PycharmProjects\Fatawi\venv\Scripts\python.exe C:/Users/USER/PycharmProjects/Fatawi/main.py Traceback (most recent call last): File "C:\Users\USER\PycharmProjects\Fatawi\main.py", line 1, in <module> import speech_recognition as sr ModuleNotFoundError: No module named 'speech_recognition'
I've tried reinstalling the library multiple times along with the PyAudio library. I ran the test that PyPi has for it and it works, but I don't know how fix it from here.
Check your python interpreter environment (the python version that's run the python file) maybe it's not the same version as python when you downloaded Speech Recognition.
Check if you activating the environemt.
For better understand see this blog in geeks for geeks might help you.
So aftergoing through some of the settings of the project file and checking the Python Interpreter it didn't have the SpeechRecognition Package. So I'm assuming that something went wrong with the install.
Thank you Faisal Faraj for the help.
I am trying to use python with mpi4py. However, when I run from mpi4py import MPI in a python environment, I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/mpi4py/MPI.so, 2): Library not loaded: /usr/local/lib/libmpi.1.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/mpi4py/MPI.so
Reason: image not found
In the specified path (/usr/local/lib/) I have what I think is a version of the required file called libmpi.12.dylib. I have looked at the source code for mpi4py and from what I can tell this file is valid, but for some reason mpi4py (MPI.so specifically) is still trying to use the .1. version.
The error message shown occurs whether I run using mpirun, mpiexec, or simply enter the import command in a terminal python session (the last one is how I generated the error message as copied here).
I would greatly appreciate any help on this. I have tried reinstalling and/or updating all the related packages and codes, but it has not solved the problem.
--- UPDATE ---
Out of desperation I tried renaming libmpi.12.dylib to libmpi.1.dylib and it worked, at least for now. I am still interested in a non-hack solution if anyone has one.
I think your problem should be resolved now, however, I had the exact same problem one iteration later;
ImportError: dlopen(/Users/<proj>/venv/lib/python3.5/site-packages/mpi4py/MPI.cpython-35m-darwin.so, 2):
Library not loaded: /usr/local/opt/open-mpi/lib/libmpi.12.dylib
Referenced from: /Users/<proj>/venv/lib/python3.5/site-packages/mpi4py/MPI.cpython-35m-darwin.so
Reason: image not found
My machine has a libmpi.20.dylib, but no libmpi.12.dylib, and although the source of mpi4py seems to check this, it did not work for me. My quick and dirty workaround was to make a symlink;
ln -s /usr/local/opt/open-mpi/lib/libmpi.20.dylib /usr/local/opt/open-mpi/lib/libmpi.12.dylib
And it worked (at least, it was able to load the library). Do note that I'm actually not using MPI locally, I'm just including the libraries so the code is more or less portable for the cluster.
-frbl
I am trying to use OpenCV 3.0 with Anaconda Python3.4. I compiled the opencv sources from Github together with the accompanying opencv_contrib repository and installed them inside a local directory.
Now, starting python I am able to import the cv2 module and do stuff like loading and displaying images. However it seems that the submodule xfeatures2d doesn't exist.
>>> import cv2
>>> cv2.xfeatures2d
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'xfeatures2d'
Interestingly I get no error if I try to import cv2.xfeatures2d (although I still can't use it then)
The shared library file exists in ~/MyOpenCV3Install/lib/libopencv_xfeatures2d.so.3.0.0. My first guess was that it is not being loaded for some reason, so I tried to force it using the LD_PRELOAD environment variable prior to launching python. However still no luck so far.
For me it doesn't work using the python3.4 environment. However, when using a python2.7 environment everything works just fine. After importing the cv2 module I can call functions like cv2.xfeatures2d.SURF_create() without errors.
Does anybody have an idea why the xfeatures2d submodule is not available when using python3.4? Is it possible that the python bindings created for opencv_contrib are not compatible with python3 yet?
EDIT:
I used the following options for the cmake configuration step:
BUILD_opencv_python3=ON
PYTHON3_EXECUTABLE=/home/mi/anaconda/envs/env3.4/bin/python3.4
PYTHON3_INCLUDE_DIR=/home/mi/anaconda/envs/env3.4/include/python3.4.m
PYTHON3_LIBRARY=/home/mi/anaconda/envs/env3.4/lib/libpython3.4m.so
PYTHON3_NUMPY_INCLUDE_DIR=/home/mi/anaconda/envs/env3.4/lib/python3.4/site-packages/numpy/core/include
PYTHON3_PACKAGES_PATH=/home/mi/anaconda/envs/env3.4/lib/python3.4/site-packages
I am trying to work with OpenCV in Python 2.7, however when I simply import cv2, I am getting this error:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cv2.py", line 9, in <module>
from VideoCapturePlayer import *
ImportError: No module named VideoCapturePlayer
I figured that VideoCapturePlayer may be in pygame or pycam, but when I import both, no problems arise.
I have searched my folders and the web for VideoCapturePlayer. My folders do not contain it, and the internet provided a .py file, but I do not know where I should put it. Any help is greatly appreciated, thank you.
Edit: I guess I should include that I am on Windows 7 64-bit
The link you provided is for downloading the entire OpenCV project, including all the libraries and bindings for C++, Java, etc. etc. For the Python bindings, it's much easier to visit my favorite module site on the Internet, Christoph Gohlke's Python Extension Packages for Windows repository. Find the OpenCV section, pick AMD64 or Win32, pick py2.7 or py2.6, and wait a bit for the self-extracting archive to download. Run it, hit OK for all the prompts, and you should be all set. Fire up IDLE or run python from the command line, and running import cv2 should give you no response at all - indicating that everything got set up just fine.
Good luck!
I'm doing some image analysis for my research, and it involves using CellTool (http://pantheon.yale.edu/~zp2/Celltool/), Python, and numpy. I'm on a OS X 10.8.3. On my old laptop that crashed, I was able to run my commands fine, but I got a new one and things are not going as smoothly!
I believe I have CellTool and numpy installed correctly, and I'm just using Python 2.7.2 that's standard on Mac. But when I try to run this python script "calculate_distances.py" command, I get this error:
Yuxins-MacBook-Pro:Modified_Contours yuxinsun$ python calculate_distances.py
Traceback (most recent call last):
File "calculate_distances.py", line 24, in <module>
normals = contours[n-1].inward_normals()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/contour/contour_class.py", line 384, in inward_normals
import celltool.numerics.fitpack as fitpack
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/__init__.py", line 1, in <module>
from fitpack import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/fitpack.py", line 34, in <module>
import _fitpack
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/_fitpack.so, 2): Library not loaded: /usr/local/lib/libgfortran.2.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/_fitpack.so
Reason: image not found
And I have no idea what any of it means...I only need to run this python script and get the file that it spits out.
Am I just missing the "fitpack" whatever that is? If so, how do I install it? Or what can I do to fix this problem.
You need to make sure you have those installed per installation requirements:
If one of the above binary installers did not suit your needs,
please install Celltool from the source code.
This depends on only three things:
1.Python (version 2.3 or later).
2. NumPy 1.0.4 or later.
3. Working C/C++ and Fortran compilers.
and it looks like your Fortran compiler libs are not installed.
This might be helpful: https://scicomp.stackexchange.com/questions/2469/how-should-i-install-a-fortran-compiler-on-a-mac-os-x-10-x-x-4