简体   繁体   English

`pip:error:运行后没有名称pip install -r requirements.txt`的命令

[英]`pip: error: No command by the name pip install -r requirements.txt` after running

I am trying to create a boostrap.py script that will create a virtualenv and install requirements from a requirements.txt file. 我正在尝试创建一个boostrap.py脚本,该脚本将创建virtualenv并从requirements.txt文件安装需求。 Other contributors to my project should be able to checkout the project from github and run python bootstrap.py and then source env/bin/activate to have a working install of my app. 我项目的其他贡献者应该能够从github检出项目并运行python bootstrap.py ,然后获取source env/bin/activate以有效安装我的应用程序。 Below is the script that I wrote, using this page as a guide: http://pypi.python.org/pypi/virtualenv 下面是我编写的脚本,使用此页面作为指南: http//pypi.python.org/pypi/virtualenv

import virtualenv, textwrap
output = virtualenv.create_bootstrap_script(textwrap.dedent("""
def after_install(options, home_dir):
    if sys.platform == 'win32':
        bin = 'Scripts'
    else:
        bin = 'bin'

    subprocess.call([join(home_dir,bin,'pip'),'install -r requirements.txt'])

"""))
print output

Below are the commands I am running in order to create the bootstrap and run it: 下面是我运行的命令,以便创建引导程序并运行它:

python create_bootstrap.py > bootstrap.py
python bootstrap.py env

Below is the output: 以下是输出:

New python executable in env/bin/python
Installing setuptools............done.
Installing pip...............done.
Usage: pip COMMAND [OPTIONS]

pip: error: No command by the name pip install -r requirements.txt
  (maybe you meant "pip install install -r requirements.txt")

requirements.txt looks like this: requirements.txt看起来像这样:

sqlalchemy==0.7

Any suggestions for a different practice or a tip on what I'm doing wrong would be helpful. 任何针对不同做法的建议或对我做错的提示都会有所帮助。 Thanks so much! 非常感谢!

In

subprocess.call([join(home_dir,bin,'pip'),'install -r requirements.txt'])

'install -r requirements.txt' is being treated as a single argument that contains spaces, so the subprocess module interprets this as a call to pip 'install -r requirements.txt' . 'install -r requirements.txt'被视为包含空格的单个参数,因此子流程模块将此解释为对pip 'install -r requirements.txt'的调用。

You can fix this by specifying each argument separately: 您可以通过单独指定每个参数来解决此问题:

subprocess.call([join(home_dir,bin,'pip'), 'install', '-r', 'requirements.txt'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM