小编典典

无法通过Virtualenv通过pip安装

python

以下是我运行时遇到的错误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$

阅读 210

收藏
2020-12-20

共1个答案

小编典典

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

创建环境时,它会建立一个bin目录。在该bin目录中是与环境有关的所有可执行文件。有些是脚本。如您所知,hashbang用来告诉系统使用什么解释程序来运行脚本。您可能经常在脚本顶部看到此信息:

#!/usr/bin/env python

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

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

就您而言,virtualenv正在创建如下脚本:

#!/tmp/oh no/bin/python

当系统尝试执行该命令/tmp/oh时,它将尝试使用参数no/bin/python和来执行命令/tmp/test.py/tmp/oh不存在,因此失败。

2020-12-20