【问题标题】:setuptools error in pythonpython中的setuptools错误
【发布时间】:2012-08-05 12:31:44
【问题描述】:

我是 python 新手,我正在安装 python 包,但我收到此错误

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

但是当我安装 setuptools 并运行它时,我得到了这个错误

Traceback (most recent call last):
  File "C:/Python32/yyy.py", line 7, in <module>
    execfile(convert_path('setuptools/command/__init__.py'), d)
NameError: name 'execfile' is not defined

我是 Windows 7 用户。如果有人对此有经验,请弄清楚 这是什么意思 解压压缩包,进入 pyserial-x.y 目录并运行 ?意味着我必须从命令提示符安装它

我想在 python 中使用 twitter api。当我运行它的安装文件时,它显示错误。我用记事本打开它并复制设置代码并将其粘贴到脚本中并用 yyy.py 保存并运行它,现在它给了我这样的错误

File "C:\Python26\twittersetup.py",
line 13, in <module> 
long_description=open("./README", "r").read(), 
IOError: [Errno 2] No such file or directory: './README'

python 3.2 中的这个错误器

File "C:/Python32/t.py",
line 9, in <module> 
setup(name='twitter',
NameError: name 'setup' is not defined

现在经过多次生存后,我遇到了这个错误

Traceback (most recent call last):
File "C:\Users\Sheikh\Desktop\twitter-1.9.0 (1).tar\twitter-1.9.0\setup.py",
line 47, 
in <module>""",File "C:\Python32\lib\distutils\core.py",
line 136, in setup
raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied

【问题讨论】:

  • 你到底想做什么?您可以包含上面yyy.py 文件中的代码吗?您在安装软件包时出错,然后在尝试安装 setuptools 以允许您安装软件包时出现另一个错误?
  • python 3.2 中的这个错误((文件“C:/Python32/t.py”,第 9 行,在 setup(name='twitter', NameError: name 'setup' is未定义)))))
  • 您可以编辑您的问题以添加此信息。
  • 为什么要将setup.py 复制并粘贴到单独的文件中?除了python-twitter 源目录之外,您无法从任何地方运行安装脚本。
  • 我希望您现在可以阅读。我希望你也能理解它:)

标签: python python-3.x setuptools


【解决方案1】:

setuptools 似乎不支持 python 3(至少根据 Python 包索引)。

试试distribute,它提供setuptools api并提供python3兼容性:http://pypi.python.org/pypi/distribute

看起来python-twitter 不支持 python3,所以你必须使用 Python 2.6。

2.6 的错误信息很清楚:

"C:\Python26\twittersetup.py", line 13, in <module> long_description=open("./README", "r").read(), IOError: [Errno 2] No such file or directory: './README') 

基本上,您是在尝试从另一个目录运行脚本,而不是包含 README 文件的目录。

我会重新开始,并确保您首先下载并解压缩 python-twitter 的完整源代码:http://pypi.python.org/packages/source/p/python-twitter/python-twitter-0.8.2.tar.gz

接下来,解压缩并解压源代码(7-Zip 非常适合此操作)。

然后打开 cmdcd 到解压后的目录(应该包括 README 文件和 setup.py 文件)。然后运行类似:

C:\Python2.6\python2.6.exe setup.py

【讨论】:

【解决方案2】:

execfile() 只能在 Python 2 中使用,在 Python 3 中使用 exec()

http://pypi.python.org/pypi/setuptools/ 可以看出setuptools 仅适用于python 2.3, 2.4, 2.5, 2.6 and 2.7,因此最好将其安装在其中一个而不是3.x 上。

阅读Alternative to execfile in Python 3.2+?


编辑:设置工具现在支持 Python 3.3+。

【讨论】:

    【解决方案3】:

    首先您需要从 pypi 安装 setuptools,然后您需要使用 cmd 通过命令运行 setup.py 文件。在 Windows 中使用 setup.py --help-commands 会告诉您步骤和命令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-18
      • 1970-01-01
      • 2014-03-11
      • 1970-01-01
      • 2011-01-13
      • 2011-12-16
      • 1970-01-01
      • 2014-12-29
      相关资源
      最近更新 更多