user3495809
user3495809

Reputation: 51

Import problem with numpy on Eclipse 2018-09

I'm have a problem using numpy with the latest Eclipse 2018-09 and PyDev 7.0.3. I'm using the latest Anaconda Python 3.7.0 which includes numpy version 1.15.1

I believe I have PyDev setup properly as I can run and debug python program that do not use numpy.

Whenever I try to "import numpy as np", I get this error:

ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try git clean -xdf (removes all files not under version control). Otherwise reinstall numpy.

Original error was: DLL load failed: The specified module could not be found.

I've found a work-around by adding this single directory to the system path (not the PYTHONPATH):

C:\ProgramData\Anaconda3\Library\bin

I do this outside of Eclipse and need to restart Eclipse after changing the system path.

Hopefully, someone can explain the proper way to configure PyDev so that I don't have to pollute my system path.

Thanks!

Upvotes: 3

Views: 915

Answers (2)

Bill Olsen
Bill Olsen

Reputation: 51

I have had to do a half 4 or 5 installs of anaconda python in the last half year, and I think every one has been a struggle to get numpy to work. Today I can remember only the final trick that got me past that error:

This system is clean install of Windows 10, and Eclipse version 2019-12(4.14.0) Build id 20191212-1212. 64bit. In Eclipse the Python interpreter (3.7.6) is working otherwise. And Python loads numpy from a command prompt, just not within Eclipse.

In Eclipse Navigator window, right click on a PyDev project and select properties.
On the left select PyDev - Interpreter/Grammar.
On the right 'Click here to configure an interpreter not listed'. (But this will actually configure the listed interpreter.)
Then click on Open interpreter preferences page.
Now in the left tree, select Pydev / Interpreters / Python Interpreter. On the right lower, choose the Environment Tab, On the far right lower click Add.
In the New Environment Variable window, in Name enter PATH
in Value enter \anaconda3\Library\bin

Happyness for me! It worked without having to re-start Eclipse. I had previously added the same path to the user's PATH in the Windows environment settings, without effect. I had earlier checked 'load conda env vars before run', and have left that checked.

Upvotes: 2

Fabio Zadrozny
Fabio Zadrozny

Reputation: 25332

In the interpreter configuration (window > preferences > PyDev > Interpreters > Python interpreter), you should be able to select the interpreter you want, go to the environment tab and set the PATH environment variable to be as you want (so, any launch with that interpreter will use the PATH you specified).

Now, I see you're using Anaconda... have you tried checking the Load conda env vars before load? to see if it fixes it for you? (that appears in the package tab when you select the interpreter).

Upvotes: 1

Related Questions