gpt4 book ai didi

python - 无法使用 Virtualenv 通过 pip 安装

转载 作者:IT老高 更新时间:2023-10-28 21:44:05 28 4
gpt4 key购买 nike

以下是我运行 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 目录中是所有与环境相关的可执行文件。有些是脚本。您可能知道,hashbangs 用于告诉系统使用什么解释器来运行脚本。您可能会经常在脚本顶部看到这一 pip :

#!/usr/bin/env python

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

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

在您的情况下,virtualenv 正在创建这样的脚本:

#!/tmp/oh no/bin/python

当系统尝试执行它时,它会尝试执行带有参数 no/bin/python/tmp 的命令 /tmp/oh/test.py/tmp/oh 不存在,所以失败了。

关于python - 无法使用 Virtualenv 通过 pip 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7911003/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com