0

I have python 2.7.3 installed to Mac OS 10.8. All the files are in /Library/Frameworks/Python.framework/Versions/2.7/ ...

I installed setuptools-0.6c11-py2.7 with the following /.pydistutils.cfg:

[install]
install_lib = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
install_scripts = ~/bin

I also use Eclipse Indigo Service Release 1 with PyDev installed. The Python interpreter is set up as follows:

Name: Python2.7 Location: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
System PYTHONPATH:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

Now. I want to install python_twitter-0.8.2-py2.7 package. I download the files. Run python setup.py install command

All goes well, I have an python_twitter-0.8.2-py2.7.egg in my site-packages, i have it in easy-install.pth but Eclipse is angry about unresolved imports when I do:

import twitter
import oauth2
import simplejson

[Note: oauth2, simplejson are dependancies of twitter library]

What goes wrong ?

Another thing. When I create as shell window in Geek Tools and run python file with the following code:

import sys

for pth in sys.path:
    print pth

I receive:

/Users/{Username}/Documents/Eclipse/{package name}/src
/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC

but when I run the same file with the same command in the Terminal I receive:

/Users/Mihails/Documents/Eclipse/Console/src
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/httplib2-0.7.6-py2.7.egg
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/python_twitter-0.8.2-py2.7.egg
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2-1.5.211-py2.7.egg
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/simplejson-2.6.2-py2.7-macosx-10.6-intel.egg
/usr/local/lib/wxPython-ansi-2.8.12.1/lib/python2.7/site-packages
/usr/local/lib/wxPython-ansi-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-ansi
/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
/usr/local/lib/wxPython-ansi-2.8.12.1/lib/python2.7

Bottom line.

When I try to run my project in Eclipse it would give an ImpoerError for the libraries that seem to be installed.

When I run my project through Geek Tools I don't even have site-packages in sys.path.

When I run my project from terminal everything works brilliant.

What is wrong? And how to make project to behave in absolutely similar way running from Eclipse, Terminal and Geek Tools?

I was like trying to find out for 2 days... Please anyone...

4

1 回答 1

0

尝试在 window > preferences > pydev > interpreter - python 中删除和添加您的解释器并检查那里的路径...

如果它没有抓住正确的路径,您可以尝试在那里手动设置它们。

于 2012-10-18T19:19:18.740 回答