1

I want to access python 2.7 modules in python 3.4 .I did the following but in python 2.7 it works but it is not working with python 3.4

Python 2.7 works:

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 fails:

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'
>>> 

Is there any solution for this?

Mounarajan
  • 1,357
  • 5
  • 22
  • 43
  • You probably have `nltk` installed (via `pip`?) for Python 2.7, but not for Python 3.0. If so, then you can try to install it again for Python 3.0: http://stackoverflow.com/questions/11268501/how-to-use-pip-with-python-3-x-alongside-python-2-x – musically_ut Apr 10 '15 at 08:00

2 Answers2

1

This happens to me on occasion when I install using pip and not pip3.

Try:

pip3 install nltk
MisterRios
  • 315
  • 3
  • 7
0

You probably have nltk installed (via pip?) for Python 2.7, but not for Python 3.0. If so, then you can try to install it again for Python 3.0:

How to use pip with Python 3.x alongside Python 2.x

Community
  • 1
  • 1
Mounarajan
  • 1,357
  • 5
  • 22
  • 43