I have two Anaconda environments:
- The base environment
- An R environment (containing R only)
The base environment is the default environment and does not appear in the Anaconda subdirectory envs
. Base is activated by default and in particular while the commands below are executed.
When I run python from within the Anaconda prompt (or another prompt that I have configured for Anaconda), importing numpy
works without problems.
However, when I run my scrips from my IDE (exctuing C:\my\path\to\Anaconda3\python.exe myscript.py
), the import of numpy
fails. Therefore, I have installed numpy
through pip and ended up with a broken installation. import numpy
results now in
Traceback (most recent call last):
File "D:\GoogleDrive\_Backup\Programmieren\Datathlon\econ_model.py", line 1, in <module>
import numpy as np
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
As far as I know the issue is due to different versions of numpy being used. (I want the mkl-enabled version, though).
That the right version of numpy
is not found lets me guess that I have multiple python environments somehow and that the wrong one is called by my IDE. I have no idea how this can be possible, as Anaconda is the only python resource on my PC.
How can I call the right python version from outside of the anaconda prompt? How can I configure python/Anaconda that the correct version is called by default?
I am aware that activating the base environment solves the problem when working within a shell. But if I run a single command, i.e. just call the python script without opening a shell before, I cannot activate anything (can I?).
Techincal details:
- Python 3.7
- conda version 4.6.8 win-64
- Windows 10 64bit
- IDE: Eclipse with PyDev
You can conda activate myEnvName
. Then, calling python on shell will bring you the desired python. When installing packages, always select in which environment you wish it to be installed. The default environment is base
来源:https://stackoverflow.com/questions/55460185/anaconda-cannot-find-packages-when-calling-python-interpreter-from-outside-the