I get "Undefined variable from import" error in Eclipse 3.7.2 PyDev 2.7.1 on Linux Mint Maya (Cinnamon) whenever I import a module from numpy. The problem only arises when importing numpy; other modules work just fine.
Info: numpy is compiled against the Intel MKL libraries. Python 2.7.3 [GCC 4.6.3]
example:
import numpy as np
a = np.array([1, 2])
Error message in PyDev editor: "Undefined variable from import: array"
I get similar errors for other numpy submodules.
The code runs properly either within Eclipse or in a terminal. The problem is only present in the Eclipse-PyDev editor.
The LD_LIBRARY_PATH
has to contain paths to the MKL libraries. Even if LD_LIBRARY_PATH
is set properly, it has to be explicitly specifed in Eclipse under Window > Preferences > Interpreter - Python, under the "Environment" tab on the right hand side. Add a new variable called "LD_LIBRARY_PATH" and paste the content of $LD_LIBRARY_PATH
.
Once it is done, errors will only disappear from your code if a line is added to the code which uses a numpy object so that imports are checked again.