0

I have a problem with importing the 'numpy' package in python. I'm currently using python3.4.5 in anaconda3. But when I try to run the following code,

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

I get the following error message.

Traceback (most recent call last):
  File "D:/SourceCodes/PycharmSources/trial/titanic.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Anaconda3\envs\py34\lib\site-packages\matplotlib\__init__.py", line 122, in <module>
    from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
  File "C:\Anaconda3\envs\py34\lib\site-packages\matplotlib\cbook.py", line 32, in <module>
    import numpy as np
ImportError: No module named 'numpy'

Well, I've tried uninstalling/reinstalling the numpy and pandas libraries using both the

pip uninstall numpy / pip insatll numpy
conda install -f numpy

commands, but nothing seems to solve my problem.

Thank you in advance.

cs95
  • 379,657
  • 97
  • 704
  • 746
  • 1
    Have you got multiple Python versions installed? – DavidG Nov 10 '17 at 09:50
  • yeah, I happen to have both python 3.6.1 and 3.4.5.. Could that be causing the problem? I'm using pyCharm and have selected 3.4.5 as my project interpreter by the way.. – HyeongGyu Froilan Choi Nov 10 '17 at 09:53
  • You should install it specifically for the python version you are currently running. Or, even better, use a python venv. – cs95 Nov 10 '17 at 09:53
  • Yeah you could be installing numpy for one version and then using the other. – DavidG Nov 10 '17 at 09:54
  • You can see a list of packages installed in Pycharm, and can also easily install them as well – DavidG Nov 10 '17 at 09:59
  • Well in fact, Pycharm is the very first channel that I used to install those packages. And I can see that 'numpy' is already installed for my project interpreter in the list. If that's the case, maybe having dual pythons isn't causing the problem? – HyeongGyu Froilan Choi Nov 10 '17 at 10:02
  • Okay, so I changed the project interpreter and it's now working.. I see the 'numpy' package installed in both interpreters' environment but I don't understand why one is working and the other isn't. Thanks both of you anyways :) – HyeongGyu Froilan Choi Nov 10 '17 at 10:19

1 Answers1

0

See my answer here

After trying many suggestions from various sites and similar questions, what worked for me was to uninstall all Python stuff and reinstall Anaconda only. The previous Python installation I had was not only redundant but only caused me trouble.

erezmk
  • 79
  • 8