我正在尝试为我的Django项目创建 requirement.txt 。我经历了https://pip.readthedocs.org/en/1.1/requirements.html并相应地尝试了我的 requirement.txt
Django==1.8.4
django-autocomplete-light
django-cors-headers
django-watson
django-filter
django-import-export
MySQL-python
Pillow
jsonpickle
mysql-connector-python --allow-external mysql-connector-python
python-amazon-product-api
lxml
similarityPy
coverage
django-redis-cache
redis
django-debreach
我得到的错误是:
------------------------------------------------------------
/usr/bin/pip run on Mon Dec 7 20:36:32 2015
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 262, in run
for req in parse_requirements(filename, finder=finder, options=options, session=session):
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1632, in parse_requirements
req = InstallRequirement.from_line(line, comes_from, prereleases=getattr(options, "pre", 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 2605, 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 2573, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'mysql-connector-python --allow-external mysql-connector-python', 'at', ' --allow-external mysql-connector-python')
我在这里缺少什么?
答案 0 :(得分:1)
此行在requirements.txt
文件中无效:
mysql-connector-python --allow-external mysql-connector-python
我认为这样做的格式是:
--allow-external mysql-connector-python
mysql-connector-python
即。像--allow-external mysql-connector-python
之类的东西,它将是一个命令行arg to pip本身,应该出现在它自己的行上
https://pip.readthedocs.org/en/stable/reference/pip_install/#requirements-file-format
这在pip要求文件中也是无效的(!):
apt-get install redis-server