gpt4 book ai didi

python - 如何在 Python virtualenv 中安装 gevent?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:50:39 24 4
gpt4 key购买 nike

我正在尝试使用 virtualenv在我的 Ubuntu 14.04 服务器上,但我似乎无法安装 gevent。我首先激活 virtualenv,然后使用 pip 安装 gevent:

$ source venv/bin/activate
(venv)immoh@vgmt:~/immod$ sudo pip install gevent
The directory '/home/immoh/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/immoh/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): gevent in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): greenlet>=0.4.7 in /usr/local/lib/python2.7/dist-packages (from gevent)

在此之后,我尝试从 python 命令行使用它:

(venv)immoh@vgmt:~/immod$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gevent
>>>

这似乎没有用,所以我尝试按照上面消息的建议使用 sudo 的 -H 标志 安装它,但在那之后,我又无法导入 gevent :

(venv)immoh@vgmt:~/immod$ sudo -H pip install gevent
Requirement already satisfied (use --upgrade to upgrade): gevent in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): greenlet>=0.4.7 in /usr/local/lib/python2.7/dist-packages (from gevent)
(venv)immoh@vgmt:~/immoh$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gevent

有谁知道我在这里做错了什么以及我该如何解决这个问题?欢迎所有提示!

最佳答案

问题的根源是您在不应该使用的情况下使用了 sudo。在 virtualenv 中工作后,只需运行不带 sudopip,您应该不会遇到这些问题。

顺便说一句,我建议创建一个新的 virtualenv 来尝试这个,以避免您之前的尝试造成的任何问题。

关于python - 如何在 Python virtualenv 中安装 gevent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32710361/

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