I am using the Anaconda distribution with Python 3.7. Among the packages installed, I have numpy, pandas, etc. In PyCharm IDE, I have set the Project Interpreter to be the p
Get the os environment path like:
import os
os.environ['PATH']
Now, add this path to the environment variable PATH
in pycharm debugger/console output. It works.
I have actually figured out the solution. I had initially edited my System Environment Variable ‘PATH’ by adding the path to the Scripts folder in my Python executable directory. Turns out, this was NOT enough...
I had to add more paths to it, and that magically did the trick.
See below the paths I added for the System Environment Variable PATH:
C:\Users\<myusername>\AppData\Local\Continuum\Anaconda3\Scripts\
C:\Users\<myusername>\AppData\Local\Continuum\Anaconda3\Library\
C:\Users\<myusername>\AppData\Local\Continuum\Anaconda3\Library\bin\
C:\Users\<myusername>\AppData\Local\Continuum\Anaconda3\Library\mingw-w64\bin\
Now, I am not sure exactly which one path among these 4 my System was really looking for in particular. However, adding this combination sure did work for me
Even I was running the python file on command prompt, but the python.exe was from Anaconda. so when you run any python file you get,
Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see https://conda.io/activation.
you need to activate the environment by using this command
conda init cmd.exe
conda activate
you see the command window as below, with base env
(base) C:\Users\yash\Documents\pycharm_project\venv>
Doing this I resolved this error
ImportError: numpy.core.multiarray failed to import Traceback (most recent call last): File "opencv_p1.py", line 2, in import cv2 File "E:\Anaconda3\lib\site-packages\cv2__init__.py", line 3, in from .cv2 import * ImportError: numpy.core.multiarray failed to import
In case you want to deactivate the conda use
conda deactivate
Please follow this link in case you have any doubt https://conda.io/activation
Edit your System Environment Variable "PATH’ (refer steps here) by adding below given path.
Note: Follow this step if you already have numpy installed.
If using anaconda:
C:\Users\<username>\AppData\Local\Continuum\Anaconda<version>\Library\bin\
If using independent python interpreter:
C:\Users\<username>\AppData\Roaming\Python\Python<version>\Library\bin
For PyCharm users wanting an easy fix, this issue is fixed in PyCharm 2019.2.