-
Notifications
You must be signed in to change notification settings - Fork 12
python cgi连接mysql出现apache internal server error
Shuang0420 edited this page Jul 28, 2016
·
1 revision
python-cgi 连接 mysql 时出现 apache-internal-server-error。 发现是 import MySQLdb 时找不到模块,推测是路径问题。
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.7/site-packages/lctool-0.1.0.dev0-py2.7.egg', '/usr/local/lib/python2.7/site-packages/BeautifulSoup-3.2.1-py2.7.egg', '/usr/local/lib/python2.7/site-packages/six-1.10.0-py2.7.egg', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']
suredeMBP-2:site-packages Shuang$ cd /usr/local/lib/python2.7/site-packages
suredeMBP-2:site-packages Shuang$ ls
BeautifulSoup-3.2.1-py2.7.egg enum34-1.1.6.dist-info python_dateutil-2.4.2.dist-info
MySQL_python-1.2.5.dist-info external pytz
MySQLdb futures-3.0.3.dist-info pytz-2016.4.dist-info
OpenSSL gensim redis
PyDispatcher-2.0.5.dist-info gensim-0.12.4.dist-info redis-2.10.5.dist-info
Scrapy-1.1.0.dist-info google retrying-1.3.3.dist-info
Twisted-16.2.0.dist-info gridfs retrying.py
_cffi_backend.so hubstorage retrying.pyc
_mysql.so hubstorage-0.23.1.dist-info ruamel
..........
显而易见,这是放第三方模块的地方。
['/Applications/XAMPP/xamppfiles/cgi-bin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
suredeMBP-2:site-packages Shuang$ cd /Library/Python/2.7/site-packages
suredeMBP-2:site-packages Shuang$ ls
README easy_install.pyc queuelib-1.4.2.dist-info vboxapi
_markerlib pip requests vboxapi-1.0-py2.7.egg-info
beautifulsoup4-4.4.1.dist-info pip-7.1.2.dist-info requests-2.9.0.dist-info wheel
bs4 pkg_resources setuptools wheel-0.26.0.dist-info
easy_install.py queuelib setuptools-19.1.1.dist-info
这里并没有 MySQLdb。
sudo cp -r /usr/local/lib/python2.7/site-packages/ /Library/Python/2.7/site-packages
[[TOC]]