如何在 Python 3.1 中安装 argparse?

发布于 2024-10-11 04:38:01 字数 5864 浏览 2 评论 0原文

我试图让 argparse 安装在 Python 3.1 中,但是当我 easy_install 时,我从 setup.py 中得到 UnicodeDecodeError

(ve31) offline@void (projects) $ easy_install argparse
install_dir /Users/offline/tmp/ve31/lib/python3.1/site-packages/
Searching for argparse
Reading http://pypi.python.org/simple/argparse/
Reading http://code.google.com/p/argparse/
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Page at http://pypi.python.org/simple/argparse/ links to .py file(s) without version info; an index scan is required.
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Reading http://argparse.python-hosting.com/file/trunk/argparse.py?rev=6&format=raw
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Best match: argparse 1.1
Downloading http://pypi.python.org/packages/source/a/argparse/argparse-1.1.zip#md5=087399b73047fa5a6482037411ddc968
Processing argparse-1.1.zip
Running argparse-1.1/setup.py -q bdist_egg --dist-dir /var/folders/jj/jjpHKlEGGDCZAkn87y0qBU+++TI/-Tmp-/easy_install-DQ9nUb/argparse-1.1/egg-dist-tmp-zMCdC1
Traceback (most recent call last):
  File "/Users/offline/tmp/ve31/bin/easy_install", line 9, in <module>
    load_entry_point('distribute==0.6.14', 'console_scripts', 'easy_install')()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1855, in main
    with_ei_usage(lambda:
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1836, in with_ei_usage
    return f()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1859, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/local/Cellar/python3/3.1.3/lib/python3.1/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python3/3.1.3/lib/python3.1/distutils/dist.py", line 919, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python3/3.1.3/lib/python3.1/distutils/dist.py", line 938, in run_command
    cmd_obj.run()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 342, in run
    self.easy_install(spec, not self.no_deps)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 582, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 612, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 802, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1079, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1068, in run_setup
    run_setup(setup_script, args)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/sandbox.py", line 30, in run_setup
    lambda: exec(compile(open(
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/sandbox.py", line 71, in run
    return func()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/sandbox.py", line 31, in <lambda>
    "setup.py"
  File "/Users/offline/tmp/ve31/lib/python3.1/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 39: ordinal not in range(128)

如何将这个非常有用的模块放入我的 Python 3.1 virtualenv 中?

更新

为了完整起见,这里是有问题的运行时:

$ python3.1
Python 3.1.3 (r313:86834, Jan  2 2011, 21:23:36) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin

$ virtualenv5 --version
1.3.4.5

$ uname -a # OSX 10.6.6
Darwin void.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386

I am trying to get argparse to install in Python 3.1, but I get a UnicodeDecodeError out of setup.py when I easy_install it:

(ve31) offline@void (projects) $ easy_install argparse
install_dir /Users/offline/tmp/ve31/lib/python3.1/site-packages/
Searching for argparse
Reading http://pypi.python.org/simple/argparse/
Reading http://code.google.com/p/argparse/
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Page at http://pypi.python.org/simple/argparse/ links to .py file(s) without version info; an index scan is required.
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Reading http://argparse.python-hosting.com/file/trunk/argparse.py?rev=6&format=raw
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Reading http://argparse.python-hosting.com/
Download error: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found!
Best match: argparse 1.1
Downloading http://pypi.python.org/packages/source/a/argparse/argparse-1.1.zip#md5=087399b73047fa5a6482037411ddc968
Processing argparse-1.1.zip
Running argparse-1.1/setup.py -q bdist_egg --dist-dir /var/folders/jj/jjpHKlEGGDCZAkn87y0qBU+++TI/-Tmp-/easy_install-DQ9nUb/argparse-1.1/egg-dist-tmp-zMCdC1
Traceback (most recent call last):
  File "/Users/offline/tmp/ve31/bin/easy_install", line 9, in <module>
    load_entry_point('distribute==0.6.14', 'console_scripts', 'easy_install')()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1855, in main
    with_ei_usage(lambda:
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1836, in with_ei_usage
    return f()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1859, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/local/Cellar/python3/3.1.3/lib/python3.1/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python3/3.1.3/lib/python3.1/distutils/dist.py", line 919, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python3/3.1.3/lib/python3.1/distutils/dist.py", line 938, in run_command
    cmd_obj.run()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 342, in run
    self.easy_install(spec, not self.no_deps)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 582, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 612, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 802, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1079, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/command/easy_install.py", line 1068, in run_setup
    run_setup(setup_script, args)
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/sandbox.py", line 30, in run_setup
    lambda: exec(compile(open(
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/sandbox.py", line 71, in run
    return func()
  File "/Users/offline/tmp/ve31/lib/python3.1/site-packages/distribute-0.6.14-py3.1.egg/setuptools/sandbox.py", line 31, in <lambda>
    "setup.py"
  File "/Users/offline/tmp/ve31/lib/python3.1/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 39: ordinal not in range(128)

How can I get this very useful module into my Python 3.1 virtualenv?

Update

For completeness, here is the runtime in question:

$ python3.1
Python 3.1.3 (r313:86834, Jan  2 2011, 21:23:36) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin

$ virtualenv5 --version
1.3.4.5

$ uname -a # OSX 10.6.6
Darwin void.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坐在坟头思考人生 2024-10-18 04:38:01

我从 pypi 下载了该文件,解压缩并运行 python3 setup.py install 。没有错误。这是 Ubuntu 10.04 上的 Python 3.1.2 的情况。

$ wget http://argparse.googlecode.com/files/argparse-1.2.1.tar.gz
$ tar -zxvf argparse-1.2.1.tar.gz
$ cd argparse
$ python3 setup.py install

easy_install 也有效,但我有 Distribute 0.6.4。

我怀疑 Distribute 0.6.14 中的错误是导致您的问题的原因。提交错误报告。 :)

I downloaded the file from pypi, unzipped it and ran python3 setup.py install. No errors. That's with Python 3.1.2 on Ubuntu 10.04.

$ wget http://argparse.googlecode.com/files/argparse-1.2.1.tar.gz
$ tar -zxvf argparse-1.2.1.tar.gz
$ cd argparse
$ python3 setup.py install

easy_install worked as well, but I have Distribute 0.6.4.

I suspect a bug in Distribute 0.6.14 is the cause of your problem. File a bug report. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文