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

查看:38
本文介绍了`pip: error: No command by name pip install -r requirements.txt` 运行后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 boostrap.py 脚本,该脚本将创建一个 virtualenv 并从一个 requirements.txt 文件安装需求.我的项目的其他贡献者应该能够从 github 签出该项目并运行 python bootstrap.py 然后 source env/bin/activate 来安装我的应用程序.下面是我写的脚本,使用这个页面作为指南:http://pypi.python.org/pypi/virtualenv

I am trying to create a boostrap.py script that will create a virtualenv and install requirements from a requirements.txt file. 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. Below is the script that I wrote, using this page as a guide: 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

输出如下:

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 看起来像这样:

requirements.txt looks like this:

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' 被视为包含空格的单个参数,因此子进程模块将其解释为对 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'.

您可以通过单独指定每个参数来解决此问题:

You can fix this by specifying each argument separately:

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

这篇关于`pip: error: No command by name pip install -r requirements.txt` 运行后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆