numpy resolution problem


PyCharm is failing to resolve imports from numpy. If I write:
import numpy as np
import numpy.core.umath as np2

def my_exp(t):
    return np.exp(t)

def my_exp2(t):
    return np2.exp(t)

PyCharm resolves np2.exp() correctly but fails to find np.exp() with a "Cannot find reference 'exp' in".
After working out that the in question is the numpy one (it makes sense but there are a lot of s floating around) I think I have narrowed the problem down to how the numpy skeleton is created. The original numpy is quite elaborate and imports several submodules into the main namespace. In particular there is the line:


which is I think responsible for np.exp() running. However despite the numpy being 216 lines long, the stub in the skeleton is empty. Is there a way around this? I use numpy in practically all my code and it is for sprawling libraries like this that code completion and resolving on the fly are most useful so I would really like to know how to fix this.

I'm using PyCharm 4.0.4 Professional with numpy 1.9.1 in an Anaconda virtual environment. The interpreter seems to work correctly, PyCharm finds the correct packages in the correct locations and the normal np.exp works from the console.

EDIT: So I've looked a bit further into skeletons and am more confused but possibly closer to knowing how to fix the problem. The GitHub repository for python skeletons has a non-empty skeleton for numpy's which dates to July last year but references version 1.8. It seems that I should clone the github repository and edit the skeleton and can probably manage to do that if there is only one numpy but if that were the case, how have I got an empty one? Is something picking out versions? I have now checked that the github skeletons-helpers version of the numpy is in my folder but am not sure how to make it, and therefore any update I might make, available to my project which is referring to an empty file numpy/ stub.

EDIT EDIT: This appears to be the same issue as bugs PY 13124 and PY 14971. The former of which has been open since May last year.

EDIT EDIT EDIT: And also PY 11316 from November 2013
How does numpy.core import exp into its namespace?
As I understand it exp is defined in numpy.core.ufunc which is imported to the numpy namespace in numpy/ (my 1.9.1 version attached) either by
from . import core
from core import *

on lines 181 and 182

online 208.

So the more complicated "core" import statement is a completely ordinary import which works while calling numpy.exp involves a much more complex import process which hasn't translated to successful code navigation in the binary skeletons. I believe I am running exactly the same code in each case but the normal invocation fails as described as far as PyCharm code analysis is concerned.
Hi bunbury,

this is related to PY-11316 and will be fixed in next PyCharm release
Great news and good to know.

This bug appears to be back with Intellij IDEA ULTIMATE 2017.3.

Code inspection can't find reference 'arange', 'dot', 'maximum', 'sqrt', 'square', 'zeros', etc in ''


Same here, the bug is back and it makes the code hard to clean, as warnings are showing up all the time. 


Hi all! Please vote & comment for PY-23521. Unfortunately, I had not much luck reproducing it so any tips are greatly appreciated!


Same issue here with arange - PyCharm 2018.1


I, too, have the same issue with np.arange on PyCharm Professional 2018.2.5. Is this ever going to be fixed? It is so annoying.


Please sign in to leave a comment.