osx - When a python module (cairo) is installed successfully but fails to import in python, what could be the issue? -
when python module installed fails import in python (via pycharm ide), issue? checklist should follow diagnose problem in case , in future when module installs later fails import?
for specific case, installed vector graphics module python called cairo. http://cairographics.org/releases/pycairo-1.8.8.tar.gz
see successful install below:
sudo python setup.py install cairo >= 1.8.8 detected creating pycairo.pc creating src/config.h running install running build running build_ext running install_lib creating /library/python/2.7/site-packages/cairo copying build/lib.macosx-10.9-intel-2.7/cairo/_cairo.so -> /library/python/2.7/site-packages/cairo running install_data creating /system/library/frameworks/python.framework/versions/2.7/include/pycairo copying src/pycairo.h -> /system/library/frameworks/python.framework/versions/2.7/include/pycairo copying pycairo.pc -> /system/library/frameworks/python.framework/versions/2.7/lib/pkgconfig running install_egg_info writing /library/python/2.7/site-packages/pycairo-1.8.8-py2.7.egg-info everything seemed proceed smoothly, later module failed import when called in python: importerror: no module named cairo.
one possibility installed in wrong directory - /library/python/2.7/site-packages/. possibility should somehow telling python location of module explicitly. i.e.: /library/python/2.7/site-packages/cairo, based on output of install script found above.
it quite odd, because cairo nowadays in /library/python/2.7/site-packages/, , able import other libraries such pil found in same directory.
based on aikid's suggestion, tried using pip installed packages. this, got long list, including module called pycairo. tried importing both pycairo , cairo , still got import error. it's interesting "cairo" found in /library/python/2.7/site-packages/cairo, "pycairo" found after phone call of pip.get_installed_distributions(). seems distribution called pycairo, , module called cairo. import cairo should work, either way both imports fail.
based on christopher's suggestion, checked /system/library/frameworks/python.framework/versions/2.7/lib/python2.7/ directory , did not find cairo. same token, did not find pil (the python imaging library). still able import pil, found in /library/python/2.7/site-packages/, cairo.
python 2.7.5 (default, aug 25 2013, 00:04:04) [gcc 4.2.1 compatible apple llvm 5.0 (clang-500.0.68)] on darwin type "help", "copyright", "credits" or "license" more information. >>> import pil, cairo traceback (most recent phone call last): file "<stdin>", line 1, in <module> importerror: no module named cairo
you can run python interactive mode , next steps confirm lib paths:
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" more information. >>> import os >>> os.path <module 'posixpath' '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/posixpath.pyc'> as can see, /system/library/frameworks/python.framework/versions/2.7/lib/python2.7/ path in system.
you might have multiple versions of python, can confirm 1 using doing this.
python osx install pycharm cairo
No comments:
Post a Comment