简体   繁体   中英

“Python module not found” error on installed module

I am on Mac 10.6.8 with MAMP server installed. I have installed both Scrapy and MySQLdb module under Python 2.6

When i import MySQLdb module from a python command line or in another project i see no error and it's working as expected. However when i import MySQLdb module in Scrapy project i get import error ("ImportError: No module named MySQLdb").

I am not a Python guru and such behavior is quite unexpected. Why is that happening ? How this can be fixed ?

$ which python
/opt/local/bin/python (which is a symlink to "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6")

$ which scrapy
/usr/local/bin/scrapy

You have multiple Python instances installed (eg, one is OS X built-in, another from MAMP). Check that those modules are actually installed in MAMP Python 2.6 (see what site-packages directory they reside in).

If you installed a module using easy_install from the built-in Python, you would not be able to use it from other Python instances.

PS Why use MAMP at all? Mac OS X already has all the components you need (Apache, MySQL, Python).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM