无法使用 Virtualenv 通过 pip 安装

2024-01-12

以下是我运行时遇到的错误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 环境。这就是它发生的原因:

当您创建环境时,它会设置一个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 and /tmp/test.py. /tmp/oh不存在,所以失败。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法使用 Virtualenv 通过 pip 安装 的相关文章

随机推荐