在Unix上安装Python安装工具以运行用于Python的Tweepy Twitter客户端

时间:2012-11-10 05:29:48

标签: python unix install tweepy

我正在尝试在我的Unix帐户上运行Twitter的Tweepy客户端。每当我尝试使用命令运行Tweepy的设置时:

python setup.py

我收到此错误:

Traceback (most recent call last):
File "setup.py", line 3, in ?
from setuptools import setup, find_packages
ImportError: No module named setuptools

现在我在一些论坛上搜索,发现我需要添加设置工具文件。找到的文件

setuptools-0.6c11-py2.7.egg

我FTP - 将此文件编辑到我的unix目录,其中我有Tweepy客户端目录和我使用Tweepy的程序。

现在,每当我尝试使用命令

安装设置工具时
python setuptools-0.6c11-py2.7.egg

我收到错误:

python setuptools-0.6c11-py2.7.egg
  File "setuptools-0.6c11-py2.7.egg", line 2
    if [ `basename $0` = "setuptools-0.6c11-py2.7.egg" ]
                   ^
SyntaxError: invalid syntax

任何线索/建议我在这里做错了什么?

3 个答案:

答案 0 :(得分:3)

不要使用setuptools,请使用distribute。 Setuptools已旧并且已弃用。直到python 3.4与packaging / distutils2在一起使用distribute,这是旧的setuptools / distutils的一个分支。

只需下载分发源tarball,解压缩并运行python setup.py install。或者,您可以下载distribute-setup.py并运行它。

答案 1 :(得分:1)

要安装tweepy,请在virtualenv中运行:

(venv) $ pip install tweepy

要创建虚拟环境并安装setuptools / distribute / easy_install,pip和virtualenv,请运行:

$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py venv
$ source ./venv/bin/activate

taken from here

答案 2 :(得分:0)

setuptools documentation建议使用sh setuptools-0.6c11-py2.7.egg代替python setuptools-0.6c11-py2.7.egg

你从python得到SyntaxError,因为setuptools-0.6c11-py2.7.egg以shell脚本开头:

#!/bin/sh
if [ `basename $0` = "setuptools-0.6c11-py2.7.egg" ]
then exec python2.7 -c "import sys, os; sys.path.insert(0, os.path.abspath('$0')); from setuptools.command.easy_install import bootstrap; sys.exit(bootstrap())" "$@"
else
  echo $0 is not the correct name for this egg file.
  echo Please rename it back to setuptools-0.6c11-py2.7.egg and try again.
  exec false
fi
PK\00\00\00\00F\A3\E...