1

安装 iMac 10.7.4、Eclipse Indigo、Pydev、Python 2.7

我正在尝试安装 Tweepy API,但对于任何初学者程序员来说,文档都有点稀疏。我以为我已经安装了它,因为我已经将必要的文件下载到了我的应用程序文件夹并输入了“python setup.py install”

但是我现在才了解 Pythonpath 和正确的使用方式import

谁能告诉我应该在哪里找到 Tweepy 文件夹,以便我可以将它添加到 PythonPath

我的 Python“系统库”都位于我认为是标准目录配置中

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/

编辑:PythonPath 打印输出

['/Users/me/Documents/workspace/Tweeter/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/tweepy-1.7.1-py2.7.egg',

'/Users/me/Documents/workspace/Tweeter/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/tweepy-1.7.1-py2.7.egg', 

'/Applications/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/pydev_sitecustomize', 

'/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', '/Library/Python/2.7/site-packages', '/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/tweepy-1.7.1-py2.7.egg', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip']
4

1 回答 1

2

您可以将其放在 PYTHONPATH 中的文件夹中。

要知道您的 PYTHONPATH 中有哪些文件夹,您可以运行此 python 代码

import sys
print sys.path

此外,有时您还可以在当前工作目录中添加包。

或者把它放在任何地方(可能你必须添加名为 __init__.py 的空文件)然后在使用前执行此操作,

import sys
sys.path.append('/absolute/path/to/your/tweepyparentdir')
于 2012-06-19T13:06:21.743 回答