I just installed Opencv 3.2 using conda forge on Anaconda with python 3.6. While using bash to run import cv2 works alright, running this command on fish shell outputs this error message.
import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/vicarious/anaconda/lib/python3.6/site-packages/cv2.so, 2): Library not loaded: #rpath/libopencv_hdf.3.2.dylib
Referenced from: /Users/vicarious/anaconda/lib/python3.6/site-packages/cv2.so
Reason: image not found
I checked out this question and added set -x DYLD_FALLBACK_LIBRARY_PATH /Users/vicarious/anaconda/lib/ $DYLD_FALLBACK_LIBRARY_PATH fish config file which did not help.
I also disabled MacOS Sierra SIP as it apparently does not let DYLD_FALLBACK_LIBRARY_PATH to be changed. But I still get the same error.
What should I do?
Works for me using fish as my default shell on macOS Sierra 10.12:
python
Python 3.6.0a3 | packaged by conda-forge | (default, Jul 12 2016, 15:51:25)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.__version__)
3.2.0
>>> exit()
If it works in bash but not fish then your bash environment is probably defining an environment var that isn't present in the fish environment or has a different value. Also, I installed opencv2 using conda install -c conda-forge opencv. If you built it from source or installed it in some other manner that is likely a factor.
Related
I have successfully installed gnureadline using both pip (2.x) and pip-3.5. Although importing it in Python2.7 works perfectly, in Python 3.5 it throws the following exception:
Python 3.5.1 (default, Jan 31 2016, 04:03:04)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gnureadline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnureadline.so, 2): Symbol not found: _PyInt_AsLong
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnureadline.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnureadline.so
The weird thing is that python looks for the package in the Python2.7 path.
The platform is OSX 10.11.3.
You have to check your PYTHONHOME env variable.
check it with echo $PYTHONHOME, it should point to 3.5 version ,
if it's not true, fix it by the following command
export PYTHONHOME=/full path to appropriate python libs/
After checking the sys.path variable as BasicWolf pointed out, I noticed that the 2.7 site packages were included independent of the python version that I run. This happened due to an override of the PYTHONPATH env variable in my .bashrc file:
export PYTHONPATH=~/Library/Python/2.7/lib/python/site-packages/
I'm trying to use python's iGraph module on my iMac running OSX 10.9.4. I've followed the steps on igraphs' front page for mac installation bur when I go to import igraph from the terminal, this is what I get.
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named igraph
Here are the steps that I've attempted to install igraph:
I intially had some problems with my pkg-config not being writable (I'm new to homebrew), so I followed these steps
brew install homebrew/science/igraph like posed here and linked the formula with brew link igraph and it brewed with no problems.
pip install python-igraph also finished cleanly.
From the igraphs documentation, this is all I need to do.
I looked into this answer but couldn't get the following line to work.
DYLD_LIBRARY_PATH=/usr/local/lib python -m igraph.test.__init__
/usr/bin/python: No module named igraph.test
This might suggest where the problem is but I don't know where to go from here.
Other information:
I have python installed through brew, but I'm not sure if that is causing the conflict. Regardless, Python2.7 should be the default python. I've installed other modules like numpy, scipy, and matplotlib with no problems.
Let me know if you need/want any other info.
I have mac os x 10.9. I downloaded opencv-python using homebrew and I have both the python 2.7 and python 3.4 versions off of the main python site, downloaded the usual way with macs. I need to use opencv, but they do not have a download package for macs so I used homebrew:
brew tap homebrew/science
brew install opencv
When I type python into the terminal, and then type import cv, I get a segmentation error and python quits unexpectedly. The same thing happens in IDLE. For python 3.4, I get a no module error. Here it is:
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/aurora_alvarez-buylla/cv.py", line 1, in <module>
from cv2.cv import *
ImportError: No module named 'cv2'
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Segmentation fault: 11
and then it quits unexpectedly. Does anyone know what is going on? Frankly I have spent way too much time on this opencv issue and am finding it very frustrating. Thank you!
Chris Muktar pointed in this thread that the problem is caused by the conflict between the system Python and brewed Python. Following that idea, I resolved this issue by removing the system python and re-installing opencv:
$ cd /usr/bin
$ sudo mv python python.bak
$ brew uninstall opencv
$ brew install opencv
I thought I'd move from using Tkinter to wxPython, but I'm having some troubles. All I get is this:
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wx
I have installed wxPython. When I run the uninstaller I clearly see that wxPython IS installed:
1. wxPython3.0-osx-cocoa-py2.7 3.0.0.0
Enter the number of the install to examine or 'Q' to quit:
When I start Python I see that my version should match the version of wxPython:
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
I'm on OS X 10.7.5 32-bit.
Any help would be awesome! :)
Macs can have multiple versions of Python installed. Are you sure that you installed wxPython for the same python you invoke with the interpreter?
Try, which python, and make sure that this version of python has a wxredirect.pth file in site-packages pointing to the wxPython installation. (If it doesn't search for wxredirect.pth.)
Here's one version on my system...
> which python2.6
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
> more /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/wxredirect.pth
import site; site.addsitedir('/usr/local/lib/wxPython-3.0.0.0/lib/python2.6')
#import site; site.addsitedir('/usr/local/lib/wxPython-2.9.1.1/lib/python2.6')
#import site; site.addsitedir('/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.6')
Here, btw, I can comment out lines in the wxredirect.pth to choose the version of wxPython I want to use.
I just find the same problem.
I used brew install wxpython to install it on mac.
I try the method above but no use.
I happen to find the solution when I install another package, it showen below:
brew install tbb
Downloading https://homebrew.bintray.com/bottles/tbb-2017_U7.sierra.bottle.t
############################################################ 100.0%
==> Pouring tbb-2017_U7.sierra.bottle.tar.gz
==> Caveats
Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
mkdir -p /Users/ningrongye/.local/lib/python2.7/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-
packages")' >> /Users/ningrongye/.local/lib/python2.7/site-
packages/homebrew.pth`
this is what homebrew said and I just try those, and it works.
ningrong
I have Python 2.7 and 3.7 .
In /usr/local/bin/ there are symbolic links for 2.7 and 3.7 Python versions and also symbolic links for pip.
I've installed wxPython with pip3
pip3 install -U wxPython
Then i checked the installation for Python3
myname$ python3
Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'4.0.4 osx-cocoa (phoenix) wxWidgets 3.0.5'
Antonio
In my case it worked by resetting the brew environment to 2.7:
brew link --overwrite python#2
I am trying to set up working environment on
OS X 10.6.6, XCode3.2, fink using python and cocoa frameworks. I scanned few references in the net, however nothing worked for me.
I have python2.6 installed via fink together with a pyobjc-py26. When I run a python shell in the terminal I get:
localhost:PyObjCTut stymek$ which python
/usr/bin/python
localhost:PyObjCTut stymek$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import objc
>>>
Everything is OK.
When I try to build the basic code from the Xcode (e.g. 1. default Python + Cocoa template 2. example from here), the python is not able to find objc module. Why?
Traceback (most recent call last):
File "main.py", line 10, in <module>
import objc
ImportError: No module named objc
I was struggling with almost similar troubles after manually installing Python version 2.7 and 3.X...
There's no such setting in XCode - the Apple-shipped Python (v2.6) needs to be the default one.
Also, check in the /System/Library/Frameworks/Python.framework/Versions - the 'Current' symlink needs to point to the default Python v2.6