¿Cómo puedo instalar argparse en Python 3.1?

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?

Noticias

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

preguntado el 08 de enero de 11 a las 17:01

Argparse is part of 3.2 (docs.python.org/dev/library/argparse.html). it is likely that you need to get the 3.x-compatible version of argparse (or take it from 3.2). -

Can you wait until Feb 5, 2011? Then it will be part of the standard library in Python 3.2 (which is currently in Beta 2). -

Works for me on Ubuntu. What version of virtualenv did you use to set it up? I've had some troubles with virtualenv3. You might want to try the fork called virtualenv5, if you haven't already. -

I'm using virtualenv5 on Mac OSX 10.6.6. Python 3.1 version is 3.1.3, exactly. I'll amend the question accordingly. -

Better idea: use docopt en lugar de. -

1 Respuestas

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. :)

Respondido el 07 de enero de 14 a las 08:01

How would I go about testing this? virtualenv installs the latest distribute automatically when I try to create an environment... how would I force it to use an older distribute? - Chris R

@Chris R: You would have to download an older version and install it manually. See pypi.python.org/pypi/distribute/0.6.4#source-installation - Lennart Regebro

Success with Ubuntu 9.10 required wget http://python-distribute.org/distribute_setup.py y python3 distribute_setup.py in addition to the above. - John Mee

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.