Correct directory for Tweepy API to add to the PythonPath

痴心易碎 提交于 2019-12-11 05:59:38

问题


Setup iMac 10.7.4, Eclipse Indigo, Pydev, Python 2.7

I’m trying to install the Tweepy API but the documentation is a bit sparse for any beginner programmer. I thought I had it installed as I had downloaded the necessary file to my applications folder and typed 'python setup.py install'

However I’m only now learning about the Pythonpath and the correct way of using import

Can anyone tell me where I should locate the Tweepy folder so that I can add it to the PythonPath

My Python "System libs" are all located in what I believe is a standard directory configuration

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

EDIT: PythonPath Printout

['/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']

回答1:


You can place in a folder in your PYTHONPATH.

To know which folders are in your PYTHONPATH you can run this python code

import sys
print sys.path

Also sometimes you can also add packages in your current working directory.

OR put it anywhere (probably you will have to add empty file named __init__.py ) then do this before use,

import sys
sys.path.append('/absolute/path/to/your/tweepyparentdir')


来源:https://stackoverflow.com/questions/11101145/correct-directory-for-tweepy-api-to-add-to-the-pythonpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!