osx - Error importing MySQL package for Python -


i'm trying import mysql module python, more flask, though receive error. i'm using virtual environment application. here error:

    traceback (most recent call last):   file "../myapp/application.py", line 9, in <module>     flask.ext.mysql import mysql   file "/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/flask/exthook.py", line 81, in load_module     reraise(exc_type, exc_value, tb.tb_next)   file "/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/flaskext/mysql.py", line 3, in <module>     import mysqldb   file "/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/mysqldb/__init__.py", line 19, in <module>     import _mysql importerror: dlopen(/users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/_mysql.so, 2): library not loaded: /library/python/2.7/site-packages/_mysql.so   referenced from: /users/pavsidhu/documents/web-development/app/env/lib/python2.7/site-packages/_mysql.so   reason: image not found 

i can see in error says library not loaded: /library/python/2.7/site-packages/_mysql.so. i'm using virtual environment path incorrect. should /lib/python2.7/site-packages/_mysql.so.

is there way change this? thanks.

edit:

i found there terminal command on osx change library location:

 sudo install_name_tool -change libmysqlclient.18.dylib /lib/python2.7/site-packages/mysqldb/ 

though after hitting enter this:

usage: /library/developer/commandlinetools/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input 

i don't appear entering command wrong, issue?

as rule, try avoiding system python install plague. yes, basing virtualenvs on it. generate hard understand problems.

i recommend getting homebrew, installing python , mysql headers:

brew install python brew install mysql 

and basing virtualenv on python brew:

virtualenv venv --python /usr/local/bin/python 

i know, it's little more hoops jump through, make development process easier. not mention brew great aid developer in own right.

i checked if worked, took me 2 minutes working mysqldb.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -