无法使用 Virtualenv 通过 pip 安装 [英] Can't install via pip with Virtualenv

查看:34
本文介绍了无法使用 Virtualenv 通过 pip 安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我运行 pip 时得到的错误:

Below is the error I get when I run pip:

serkan$ rm -r mysite
serkan$ pwd
/Users/serkan/Desktop/Python Folder
serkan$ virtualenv mysite 
New python executable in mysite/bin/python
Installing setuptools............done.
Installing pip...............done.
serkan$ source mysite/bin/activate
(mysite)serkan$ pip install pinax
-bash: /Users/serkan/Desktop/Python Folder/mysite/bin/pip: "/Users/serkan/Desktop/Python: bad interpreter: No such file or directory
(mysite)serkan$ python pip install pinax
python: can't open file 'pip': [Errno 2] No such file or directory
(mysite)serkan$ python pip install Pinax
python: can't open file 'pip': [Errno 2] No such file or directory
(mysite)serkan$ python pip install Pinax
python: can't open file 'pip': [Errno 2] No such file or directory
(mysite)serkan$ python pip install Pinax
python: can't open file 'pip': [Errno 2] No such file or directory
(mysite)serkan$ python pip 
python: can't open file 'pip': [Errno 2] No such file or directory
(mysite)serkan$ pip
-bash: /Users/serkan/Desktop/Python Folder/mysite/bin/pip: "/Users/serkan/Desktop/Python: bad interpreter: No such file or directory
(mysite)serkan$ pip install Pinax
-bash: /Users/serkan/Desktop/Python Folder/mysite/bin/pip: "/Users/serkan/Desktop/Python: bad interpreter: No such file or directory
(mysite)serkan$ 

推荐答案

在没有空格的路径中创建您的 virtualenv 环境.这就是它发生的原因:

Create your virtualenv environment within a path without spaces. This is why it is happening:

当您创建环境时,它会设置一个 bin 目录.在那个 bin 目录中是所有与环境相关的可执行文件.有些是脚本.您可能知道,hashbangs 用于告诉系统使用什么解释器来运行脚本.您可能经常在脚本顶部看到这一点:

When you create an environment, it sets up a bin directory. In that bin directory are all the executables relating to the environment. Some are scripts. As you may know, hashbangs are used to tell the system what interpreter to use to run the script. You may see this at the top of scripts often:

#!/usr/bin/env python

如果脚本位于 /tmp/test.py,则告诉系统运行此命令以执行脚本:

If the script is at /tmp/test.py, that tells the system to run this command to execute the script:

/usr/bin/env python /tmp/test.py

就您而言,virtualenv 正在创建这样的脚本:

In your case, virtualenv is creating scripts like this:

#!/tmp/oh no/bin/python

当系统尝试执行该命令时,它会尝试使用参数 no/bin/python/tmp 执行命令 /tmp/oh/test.py./tmp/oh 不存在,所以失败.

When the system tries to execute that, it will try to execute the command /tmp/oh with the arguments no/bin/python and /tmp/test.py. /tmp/oh does not exist, so it fails.

这篇关于无法使用 Virtualenv 通过 pip 安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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