location of twitter.py file (python-twitter library) in Mac OS X 10.6.7 with Python 2.6.7
Asked Answered
P

2

0

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:

  1. tar -xvf python-twitter-0.8.3.tar.gz
  2. cd python-twitter-0.8.3
  3. python setup.py build
  4. 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?

Pons answered 28/6, 2011 at 15:7 Comment(2)
I'm not clear what you are saying - does '/usr/local/lib/python2.6/site-packages/python_twitter-0.8.3-py2.6.egg exist?Palaestra
Could you tell us everything on your PYTHONPATH? That would be sys.path in python.Sauerbraten
P
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.

Pulque answered 28/6, 2011 at 15:17 Comment(1)
Thanks a lot, I tried to edit the file Before I run the setup.py and it works! =DPons
K
0

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.

Kelpie answered 28/6, 2011 at 15:14 Comment(1)
Thanks for the answer, the second method works for me, but not for the first one. :)Pons

© 2022 - 2024 — McMap. All rights reserved.