使用python 2.6.7的Mac OS X 10.6.7中twitter.py文件(python twitter库)的位置

使用python 2.6.7的Mac OS X 10.6.7中twitter.py文件(python twitter库)的位置,python,twitter,python-twitter,Python,Twitter,Python Twitter,我的mac(/usr/local/bin/python)中安装了python 2.6.7。 之前,我安装了python twitter库。我在安装时遵循以下步骤: tar-xvf python-twitter-0.8.3.tar.gz cd python-twitter-0.8.3 python setup.py构建 python setup.py安装 但是,现在,我想修改安装模块时生成的twitter.py文件。我试图在python的SitePackages目录中找到它,但找不到它 供您参考,

我的mac(/usr/local/bin/python)中安装了python 2.6.7。 之前,我安装了python twitter库。我在安装时遵循以下步骤:

  • tar-xvf python-twitter-0.8.3.tar.gz
  • cd python-twitter-0.8.3
  • python setup.py构建
  • python setup.py安装
  • 但是,现在,我想修改安装模块时生成的twitter.py文件。我试图在python的SitePackages目录中找到它,但找不到它

    供您参考,这里是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达尔文
    /usr/local/lib/python2.6/platmac
    /usr/local/lib/python2.6/platmac/lib脚本包
    /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/站点包
    /usr/local/lib/python2.6/站点包

    我已使用“locate”命令在所有文件夹中找到它,但仍然找不到它

    有人知道在哪里可以找到twitter.py文件吗?

    简单的

    import twitter
    print(twitter.__path__)
    
    找到它在哪里?另外,
    repr(twitter)
    应该是

    <module 'twitter' from '/path/you/want/twitter.py'>
    
    
    

    在系统范围内应用修改之前,您可能还想使用设置一个很好的沙盒来测试修改。

    它位于.egg文件中,实际上是一个zip归档文件

    /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%
    

    如果要进行更改,最简单的方法是在运行setup.py之前编辑文件。在您的情况下,只需进行更改并再次运行setup.py。

    我不清楚您在说什么-是否存在“/usr/local/lib/python2.6/site-packages/python_twitter-0.8.3-py2.6.egg”?您能告诉我们您的
    PYTHONPATH
    上的所有内容吗?那将是python中的sys.path。非常感谢,我在运行setup.py之前尝试过编辑该文件,它可以正常工作=D谢谢你的回答,第二种方法对我有效,但第一种方法不行。:)