Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python3.4中访问Python2.7模块_Python_Python 2.7_Python 3.x_Module - Fatal编程技术网

在Python3.4中访问Python2.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 &

我想在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
>>> 
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