在 python 3.4 中访问 python 2.7 模块
accesing python 2.7 modules in python 3.4
我想访问 python 3.4 中的 python 2.7 模块。我做了以下操作,但在 python 2.7 中它可以工作,但它不适用于 python 3.4
Python 2.7 作品:
xxx@xxx-Dell-System-XPS-L502X:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>
Python 3.4 失败:
xxx@xxxx-Dell-System-XPS-L502X:~$ python3
Python 3.4.1 (default, Feb 27 2015, 14:48:48)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'nltk'
>>>
有解决办法吗?
您可能为 Python 2.7 安装了 nltk(通过 pip?),但没有为 Python 3.0 安装。如果是这样,那么您可以尝试为 Python 3.0:
重新安装它
How to use pip with Python 3.x alongside Python 2.x
当我使用 pip 而不是 pip3 安装时,有时会发生这种情况。
尝试:
pip3 install nltk
我想访问 python 3.4 中的 python 2.7 模块。我做了以下操作,但在 python 2.7 中它可以工作,但它不适用于 python 3.4
Python 2.7 作品:
xxx@xxx-Dell-System-XPS-L502X:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>
Python 3.4 失败:
xxx@xxxx-Dell-System-XPS-L502X:~$ python3
Python 3.4.1 (default, Feb 27 2015, 14:48:48)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'nltk'
>>>
有解决办法吗?
您可能为 Python 2.7 安装了 nltk(通过 pip?),但没有为 Python 3.0 安装。如果是这样,那么您可以尝试为 Python 3.0:
重新安装它How to use pip with Python 3.x alongside Python 2.x
当我使用 pip 而不是 pip3 安装时,有时会发生这种情况。
尝试:
pip3 install nltk