我正在使用Python 3在Windows 7上关注this tutorial。但是我收到此错误:
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
我尝试使用-r标志,如Stackoverflow响应中所述,但是我收到了这个错误。
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
这个问题的解决方案是什么?
更多信息:
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
没有显示任何内容。
这是我没有-r
标志的原因:
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
我也尝试安装pip然后使用以下命令但仍然出错:
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>
答案 0 :(得分:1)
pip
的版本(1.5.6)似乎无法识别兼容版本说明符~=
。
您可以尝试以下与~=1.9.0
相同的版本规范:
pip install django>=1.9.0
或者:
pip install django==1.9.*
在任何情况下,您可能还希望使用以下内容升级到pip
的最新版本
pip install --upgrade pip
答案 1 :(得分:0)
除非您正在阅读文件,否则请取消-r
。使用:
C:/Python34/python -m pip install django~=1.9.0