gpt4 book ai didi

python - 无法在 django shell python 中导入 readline

转载 作者:行者123 更新时间:2023-11-28 17:46:36 25 4
gpt4 key购买 nike

我在 Centos 6 Linux 上

当我尝试这个的时候

Python 2.7.3 (default, Nov 23 2012, 18:02:22)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import readline
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named readline
>>>

我尝试用 pip 安装 python readline,我明白了

 virtualenv/bin/pip-2.7 install readline
Requirement already satisfied (use --upgrade to upgrade): readline in ./virtualenv/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-linux-x86_64.egg
Cleaning up...

我该怎么办

编辑:

我也试过

[myhost]$ virtualenv/bin/python2.7
Python 2.7.3 (default, Nov 23 2012, 18:02:22)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named readline
>>>

我都试过了

(virtualenv)[aaaaaa]$ source virtualenv/bin/activate
(virtualenv)[aaaaaa]$ virt
virtualenv/ virtualenv-clone virtualenvwrapper.sh
virtualenv-2.7 virtualenvwrapper_lazy.sh virt-what
(virtualenv)[aaaaaa]$ virtualenv/bin/pip
pip pip-2.7
(virtualenv)[aaaaa]$ virtualenv/bin/pip install readline
Requirement already satisfied (use --upgrade to upgrade): readline in ./virtualenv/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-linux-x86_64.egg
Cleaning up...
(virtualenv)[aaaaa]$ python
Python 2.7.3 (default, Nov 23 2012, 18:02:22)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named readline
>>>

我也尝试了所有虚拟环境和激活。但是我又遇到了同样的错误

最佳答案

您需要actually activate the environment you want to use ,而不仅仅是从环境 bin 文件夹中运行 python 二进制文件:

$ source /path/to/envirn/bin/activate
$ pip install readline
$ python
> import readline

关于python - 无法在 django shell python 中导入 readline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17341039/

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