pip install package with space in the name fails #307

Closed
bramwelt opened this Issue Jun 16, 2011 · 6 comments

Comments

Projects
None yet
6 participants

While trying to install the PyPI package Twisted Web I was provided with this stacktrace from pip:

pip install Twisted Web

Downloading/unpacking Web
  Could not find any downloads that satisfy the requirement Web
No distributions at all found for Web

This failed, so I tried using single quotes instead, I got another error though this time from python:

pip install 'Twisted Web'

Exception:
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/pip/basecommand.py", line 130, in main
    self.run(options, args)
  File "/usr/lib/pymodules/python2.7/pip/commands/install.py", line 195, in run
    InstallRequirement.from_line(name, None))
  File "/usr/lib/pymodules/python2.7/pip/req.py", line 101, in from_line
    return cls(req, comes_from, url=url)
  File "/usr/lib/pymodules/python2.7/pip/req.py", line 41, in __init__
    req = pkg_resources.Requirement.parse(req)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2547, in parse
    reqs = list(parse_requirements(s))
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2472, in parse_requirements
    line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2440, in scan_list
    raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'Twisted Web', 'at', ' Web')

I figured, "Hey, maybe I'm not installing the right package?" so i ran:

pip search 'Twisted Web'

Twisted Web               - Twisted web server, programmable in Python.
Twisted Web2              - Twisted Web2 is a web server.

I understand that pip install does not support spaces as these are used as package name separators, but what I do not understand is why pip search supports single quotation marks and pip install does not. There are several other packages I found on PyPI that contained spaces in the name, so this is not just a package naming error.

In conclusion:
Please allow pip install to take a string as a package name argument, Thank you.

Contributor

pnasrat commented Jun 20, 2011

I think there are a couple of issues here, I don't think the naming of 'Twisted Web' is going to work with distutils/setuptools, but I could be wrong (will read the PEPs and confirm).

Search is just doing a search of pypi via the API, so it doesn't have to match a requirement.

http://packages.python.org/distribute/pkg_resources.html#requirements-parsing

So it looks as if we can have packages on pypi that don't have names that match our requirements as an installer.

requirement  ::= project_name versionspec? extras?
versionspec  ::= comparison version (',' comparison version)*
comparison   ::= '<' | '<=' | '!=' | '==' | '>=' | '>'
extras       ::= '[' extralist? ']'
extralist    ::= identifier (',' identifier)*
project_name ::= identifier
identifier   ::= [-A-Za-z0-9_]+
version      ::= [-A-Za-z0-9_.]+

Is there a workaround for this?

Contributor

qwcode commented Sep 30, 2012

Is there a workaround for this?

pip can install directly from the tar:

pip install http://twistedmatrix.com/Releases/Twisted/12.2/Twisted-12.2.0.tar.bz2

pip can install directly from the tar

Thanks. I should have known that.

Still no way to install packages with spaces? I'm having trouble setting Twisted Web under install_requires field of my setup.py file. Any advice? I also posted a SO question.

Owner

dstufft commented Jun 7, 2013

This is more or less fixed on the PyPI side of things. Packages names now must conform to a specific set of requirements. There are still a handful of packages left that do not conform but they will be migrated manually.

@dstufft dstufft closed this Jun 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment