Mona Jalal Mona Jalal - 4 months ago 23
Python Question

raise ValueError("Expected "+item_name+" in",line,"at",line[p:]) ValueError: ('Expected version spec in', 'django~=1.9.0', 'at', '~=1.9.0')

I am following this tutorial on Windows 7 with Python 3. However I get this error:

PS C:\Users\jalal> C:/Python34/python -m pip install django~=1.9.0
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 257, in run
InstallRequirement.from_line(name, None))
File "C:\Python34\lib\site-packages\pip\req.py", line 172, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "C:\Python34\lib\site-packages\pip\req.py", line 70, in __init__
req = pkg_resources.Requirement.parse(req)
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2667, in parse
reqs = list(parse_requirements(s))
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2605, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2573, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'django~=1.9.0', 'at', '~=1.9.0')

Storing debug log for failure in C:\Users\jalal\pip\pip.log

PS C:\Users\jalal> pip -v
The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
g of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:4
+ pip <<<< -v
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException


I tried it with -r flag as mentioned in an Stackoverflow response however I got this error.

PS C:\Users\jalal> C:/Python34/python -m pip install -r django~=1.9.0
Could not open requirements file: [Errno 2] No such file or directory: 'django~=1.9.0'
Storing debug log for failure in C:\Users\jalal\pip\pip.log


What's the solution to this problem?

More info:

pip 1.5.6 from C:\Users\jalal\myvenv\lib\site-packages (python 3.4)
(myvenv) PS C:\Users\jalal> pip freeze
(myvenv) PS C:\Users\jalal>


pip freeze
shows nothing.

This is what I get without
-r
flag:

PS C:\Users\jalal> C:/Python34/python -m pip install django~=1.9.0
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 257, in run
InstallRequirement.from_line(name, None))
File "C:\Python34\lib\site-packages\pip\req.py", line 172, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "C:\Python34\lib\site-packages\pip\req.py", line 70, in __init__
req = pkg_resources.Requirement.parse(req)
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2667, in parse
reqs = list(parse_requirements(s))
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2605, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2573, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'django~=1.9.0', 'at', '~=1.9.0')

Storing debug log for failure in C:\Users\jalal\pip\pip.log


I also tried installing pip and then using the following command but still got error:

PS C:\Users\jalal> myvenv\Scripts\activate
(myvenv) PS C:\Users\jalal> pip install django~=1.9.0
Exception:
Traceback (most recent call last):
File "C:\Users\jalal\myvenv\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Users\jalal\myvenv\lib\site-packages\pip\commands\install.py", line 257, in run
InstallRequirement.from_line(name, None))
File "C:\Users\jalal\myvenv\lib\site-packages\pip\req.py", line 172, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "C:\Users\jalal\myvenv\lib\site-packages\pip\req.py", line 70, in __init__
req = pkg_resources.Requirement.parse(req)
File "C:\Users\jalal\myvenv\lib\site-packages\pip\_vendor\pkg_resources.py", line 2667, in parse
reqs = list(parse_requirements(s))
File "C:\Users\jalal\myvenv\lib\site-packages\pip\_vendor\pkg_resources.py", line 2605, in parse_requireme
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "C:\Users\jalal\myvenv\lib\site-packages\pip\_vendor\pkg_resources.py", line 2573, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'django~=1.9.0', 'at', '~=1.9.0')

Storing debug log for failure in C:\Users\jalal\pip\pip.log
(myvenv) PS C:\Users\jalal>

Answer

It appears that version (1.5.6) of pip does not recognize the compatible release specifier ~=.

You can try the following version specifications which are equivalent to ~=1.9.0:

pip install django>=1.9.0

Or:

pip install django==1.9.*

In any case, you may also want to upgrade to the latest version of pip using:

pip install --upgrade pip
Comments