6

I installed textblob using pip as given here.

Now, when I try to import this in python3.4 in terminal then it says

ImportError: No module named 'textblob'

Whereas, in python2.7 it imports happily. I have tried reinstalling it. I have even reinstalled pip. What is the problem here?

TrigonaMinima
  • 1,828
  • 1
  • 23
  • 35
  • What operating system? – Lawrence Dean Vanderpool Feb 13 '15 at 22:02
  • Elementary OS - Luna. – TrigonaMinima Feb 13 '15 at 22:05
  • I can't speak to that OS specifically, but I'm pretty sure you could avoid this problem entirely by using a virtualenv. It seems like you pip installed textblob onto the PATH for python2.7, so it's not available to your py3.4 installation. This would be the solution on ubuntu: http://stackoverflow.com/questions/10763440/how-to-install-python3-version-of-package-via-pip-on-ubuntu maybe that will shed some light. – Lawrence Dean Vanderpool Feb 13 '15 at 22:08
  • How can I follow something like [this](http://radimrehurek.com/data_science_python/) using virtualenv with IPython? I can't think of a way. – TrigonaMinima Feb 13 '15 at 22:19

1 Answers1

5

Elementary OS being an Ubuntu derivative,

$ sudo apt-get install python3-pip
...
$ pip3 install textblob

should do the trick. It is possible that you have to apply some minor variation to the above due to eventual differences between Elementary and Ubuntu.

Remember that Python 2.7 and Python 3.x are two independent systems, what you install in 2.7 is definitely NOT automatically available for 3.x and the converse is equally true.

Jonathan Eunice
  • 21,653
  • 6
  • 75
  • 77
gboffi
  • 22,939
  • 8
  • 54
  • 85
  • It gives `Unable to locate package python3-pip`. I followed [this answer](http://askubuntu.com/posts/412179/revisions) which gives me pip3. After running `pip3 install textblob`, textblob is installed in for python3.2. For, python3.4 `python3.4 -m pip install textblob` did the work. I have one question though. For packages which support both python2.7 and python3.4 is there a way to install that module once and import it in both versions of python? – TrigonaMinima Feb 14 '15 at 07:01
  • How do we do it in windows? I get the same `NoModuleFoundError` – ykombinator Jun 26 '17 at 22:05