在Python3.4中访问Python2.7模块
我想在Python3.4中访问Python2.7模块 Python 2.7的工作原理:在Python3.4中访问Python2.7模块,python,python-2.7,python-3.x,module,Python,Python 2.7,Python 3.x,Module,我想在Python3.4中访问Python2.7模块 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 &
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'
>>>
xxx@xxxx-Dell-System-XPS-L502X:~$python3
Python 3.4.1(默认,2015年2月27日,14:48:48)
[GCC 4.8.2]在linux上
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>导入nltk
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为“nltk”的模块
>>>
有什么解决方案吗?您可能已经为Python2.7安装了nltk(通过pip),但没有为Python3.0安装。如果是这样,那么您可以尝试在Python 3.0中再次安装它:
当我使用pip而不是pip3安装时,这种情况偶尔会发生 尝试:
您可能已经为Python2.7安装了
nltk
(通过pip
?),但没有为Python3.0安装。如果是这样,那么您可以尝试在Python 3.0中再次安装它:
pip3 install nltk