问题
I have python 2.6.7 installed in my mac (/usr/local/bin/python). Previously, I installed python-twitter library. I follow these steps when I installed it:
- tar -xvf python-twitter-0.8.3.tar.gz
- cd python-twitter-0.8.3
- python setup.py build
- python setup.py install
But, right now, I want to modify the twitter.py file generated when I installed the module. I have tried to find it in python's site-packages directory, but I couldn't find it.
For your information, here is the PYTHONPATH:
/usr/local/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
/usr/local/lib/python2.6/site-packages/oauth2-1.5.170-py2.6.egg
/usr/local/lib/python2.6/site-packages/simplejson-2.1.6-py2.6-macosx-10.4-x86_64.egg
/usr/local/lib/python2.6/site-packages/lxml-2.3-py2.6-macosx-10.4-x86_64.egg
/usr/local/lib/python2.6/site-packages/python_twitter-0.8.2-py2.6.egg
/usr/local/lib/python26.zip
/usr/local/lib/python2.6
/usr/local/lib/python2.6/plat-darwin
/usr/local/lib/python2.6/plat-mac
/usr/local/lib/python2.6/plat-mac/lib-scriptpackages
/usr/local/lib/python2.6/lib-tk
/usr/local/lib/python2.6/lib-old
/usr/local/lib/python2.6/lib-dynload
/Users/username/.local/lib/python2.6/site-packages
/usr/local/lib/python2.6/site-packages
I have used the 'locate' command to find it in all folders, but still couldn't find it.
Anyone know where to find the twitter.py file?
回答1:
It's inside the .egg file, which is actually a zip archive.
/Library/Python/2.6/site-packages-> zipinfo python_twitter-0.8.2-py2.6.egg
Archive: python_twitter-0.8.2-py2.6.egg 60381 bytes 8 files
-rw-r--r-- 2.0 unx 122153 b- defN 16-Apr-11 16:57 twitter.py
-rw-r--r-- 2.0 unx 128307 b- defN 28-Jun-11 09:14 twitter.pyc
-rw-r--r-- 2.0 unx 1 b- defN 28-Jun-11 09:14 EGG-INFO/dependency_links.txt
-rw-r--r-- 2.0 unx 25334 b- defN 28-Jun-11 09:14 EGG-INFO/PKG-INFO
-rw-r--r-- 2.0 unx 28 b- defN 28-Jun-11 09:14 EGG-INFO/requires.txt
-rw-r--r-- 2.0 unx 397 b- defN 28-Jun-11 09:14 EGG-INFO/SOURCES.txt
-rw-r--r-- 2.0 unx 8 b- defN 28-Jun-11 09:14 EGG-INFO/top_level.txt
-rw-r--r-- 2.0 unx 1 b- defN 28-Jun-11 09:14 EGG-INFO/zip-safe
8 files, 276229 bytes uncompressed, 59457 bytes compressed: 78.5%
If you want to make changes, the easiest thing to do is to edit the file BEFORE you run setup.py. In your case, just make your changes and re-run setup.py again.
回答2:
What about a simple
import twitter
print(twitter.__path__)
to find out where it is? Also, repr(twitter)
should be something like
<module 'twitter' from '/path/you/want/twitter.py'>
You might also want to use virtualenv to set up a nice sandbox for testing your modifications before applying them system-wide.
来源:https://stackoverflow.com/questions/6508649/location-of-twitter-py-file-python-twitter-library-in-mac-os-x-10-6-7-with-pyt