如何在Python 3.1中安装argparse?

How can I install argparse in Python 3.1?

我正试图让argparse安装在python 3.1中,但当我轻松安装它时,却从setup.py中得到了一个UnicodeDecodeError

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(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.1virtualenv中?

更新

为了完整性起见,这里讨论的是运行时:

1
2
3
4
5
6
7
8
9
$ 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


这些文件从pypi downloaded the unzipped python3 setup.py install,EN和冉。没有错误。这是由Python比3.1.2与Ubuntu的。P></

1
2
3
4
$ 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

易加工安装孔_ as,but I have distribute 0.6.4。P></

在犯罪嫌疑人的错误distribute 0.6.14 is the of你问题的原因。文件错误报告。):P></