2016-02-14 92 views
1
#!/bin/bash -e 
pip install -r requirements.txt 

當我執行上面的腳本時,我得到下面的錯誤信息;pip -r錯誤在bash腳本中

Exception: 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main 
    status = self.run(options, args) 
    File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 257, in run 
    InstallRequirement.from_line(name, None)) 
    File "/usr/lib/python2.7/dist-packages/pip/req.py", line 173, in from_line 
    return cls(req, comes_from, url=url, prereleases=prereleases) 
    File "/usr/lib/python2.7/dist-packages/pip/req.py", line 71, in __init__ 
    req = pkg_resources.Requirement.parse(req) 
    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2667, in parse 
    reqs = list(parse_requirements(s)) 
    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2593, in parse_requirements 
    raise ValueError("Missing distribution spec", line) 
ValueError: ('Missing distribution spec', '\xe2\x80\x93r') 

Storing debug log for failure in /home/user/.pip/pip.log 

但如果我執行

pip install –r requirements.txt 

直接慶典,它工作正常。可能是什麼原因?

下面是我有的python和pip版本;

[email protected]:~$ python -V 
Python 2.7.6 
[email protected]:~$ pip -V 
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7) 
[email protected]:~$ 
+1

是什麼在'requirements.txt' VS'env_requirements.txt'? – wogsland

+1

是'requirements.txt'在腳本執行的env中可訪問的,具體可以在當前目錄或'$ PATH' – ritesht93

+0

抱歉抱歉。我已更新問題。兩個命令都使用「requirements.txt」。我已經將腳本文件「requirements.txt」放在同一目錄下,但它仍然不起作用 – user44332

回答

2
\xe2\x80\x93 

這是一個UTF-8編碼en dash。一定要使用通常的(ASCII)dash

換句話說,替換此:

pip install –r requirements.txt 

與此:

pip install -r requirements.txt 
+1

非常感謝。它解決了我的問題。我想這是從我從其他地方複製它以來發生的。 – user44332