7

I'm trying to use a thing in numpy.random which I import using from numpy.random import normal. PyCharm tells me this is an unresolved reference despite being able to find other things in numpy.random such as numpy.random.random.

Whenever I open up a Python shell and type from numpy.random import normal it runs fine and I can use normal just as I desire in the terminal.

Why is this?

Nanor
  • 2,400
  • 6
  • 35
  • 66

4 Answers4

11

Try File->Invalidate Caches/Restart...

This worked for me.

geekly
  • 588
  • 6
  • 10
1

One possible problem is that your interpreter setting is wrong. When you have multiple versions of python installed and only one has numpy installed, if pycharm choose the wrong interpreter, then you get the error.

laike9m
  • 18,344
  • 20
  • 107
  • 140
  • As was suggested I've created a new virtualenv with a fresh install of numpy and it still can't find it. – Nanor Feb 13 '15 at 18:35
  • So you've chosen the newly created virtualenv as project interpreter? If so , I don't know what's wrong. Maybe you should report this bug to them. – laike9m Feb 13 '15 at 18:36
  • This was my problem. I have multiple pythons installed (2.7 and 3.6). PyCharm doesn't see the 3.6. This answer help me install the correct version to the version of python that PyCharm was using: https://stackoverflow.com/a/43165320/386619 – Jay Cummins Nov 26 '17 at 15:58
1

You can also comment

# noinspection PyUnresolvedReferences

Above the line of code to ignore the error message

Joshua Wolff
  • 2,687
  • 1
  • 25
  • 42
0

I had the same problem, it is basically caused due to pycharm.But when i ran the same code in spyder it worked fine.

  • Uninstall and reinstall the package

And it works!

Kunal Raut
  • 2,495
  • 2
  • 9
  • 25