我试图用python导入MySQL模块,更确切地说是Flask,不过我收到了一个错误。我在应用程序中使用虚拟环境。错误如下:Traceback (most recent call last):
File "../myapp/application.py", line 9, in
from 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
import MySQLdb
File "/Users/pavsidhu/Documents/Web-Development/app/env/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in
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
我可以在错误中看到Library not loaded: /Library/Python/2.7/site-packages/_mysql.so。因为我使用的是虚拟环境,所以路径不正确。它应该是/lib/python2.7/site-packages/_mysql.so。在
有没有办法改变这种状况?谢谢。在
编辑:
我发现OSX上有一个终端命令可以更改库位置:
^{pr2}$
但在按回车键后,我得到了:Usage: /Library/Developer/CommandLineTools/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input
我似乎没有输入错误的命令,有什么问题吗?在