my first question here on stackoverflow. i did some research before, and people often got the same problem as i do. but their solutions didn't work out for me so far.
i've installed python3 with homebrew on my mac. the path is set in the ~/.bash_profile to
export PATH=/usr/local/bin:$PATH.
that works quite well, even with opencv3. last week i've wanted to import matplotlib... and that doesn't work.
python3 looks for its modules in python2.7 somehow. any recommendations?
MacBook-Pro:Desktop -----$ python3 webcam_test.py
Traceback (most recent call last):
File "webcam_test.py", line 3, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
import matplotlib.colorbar
File "/usr/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py", line 15, in <module>
from .transforms import (Bbox, IdentityTransform, TransformedBbox,
File "/usr/local/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/matplotlib/_path.so, 2): Symbol not found: _PyCObject_Type
Referenced from: /usr/local/lib/python2.7/site-packages/matplotlib/_path.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/matplotlib/_path.so
import sys; print(sys.path) gives me:
>>> import sys; print(sys.path)
['', '/usr/local/lib/python3', '/Users/----/Desktop', '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages', '/usr/local/Cellar/matplotlib/2.0.2/libexec/lib/python3.6/site-packages', '/usr/local/Cellar/numpy/1.13.3/libexec/nose/lib/python3.6/site-packages', '/usr/local/lib/python2.7/site-packages', '/usr/local/Cellar/matplotlib/2.0.2/libexec/lib/python2.7/site-packages', '/usr/local/Cellar/numpy/1.13.3/libexec/nose/lib/python2.7/site-packages', '/usr/local/opt/opencv/lib/python2.7/site-packages', '/usr/local/opt/opencv/lib/python3.6/site-packages']
>>>
seems a bit long to me...
edit 2:
just checked my /usr/local/bin/ . it's a bit messy i guess. amongst other files there are aliases of python2, python2.7, python3, python3.6, python3.6m and pythonX.X-config for each version. but no python itself. can i remove some of those? and shouldn't there be python files itself?
edit3:
so today i deleted everything and started from scratch. python3 with brew numpy and even opencv3 worked fine. import cv2 made no problems at all. then i tried to import matplotlib which threw
mport matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: bad magic number in 'matplotlib': b'\x03\xf3\r\n'
so i checked my sys.path
>>> sys.path
['', '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages', '/usr/local/opt/opencv/lib/python2.7/site-packages', '/usr/local/opt/opencv/lib/python3.6/site-packages']
2.7 shoulnd't be in there, right? how can i remove this one? any other recommendations?