Import NumPy on PyCharm

Question:

I’m trying to import NumPy on PyCharm.

Using the PyCharm terminal and Miniconda I’ve launched the command:

conda install numpy

And this was the output:

Fetching package metadata: ....
Solving package specifications: ....................
# All requested packages already installed.
# packages in environment at C:Users...Miniconda3:
#
numpy                     1.10.4                   py35_0

So I run my project but the terminal said:

ImportError: No module named 'numpy'

On my project bar I can see two different folders, the one with my project and another one with the external libraries.

Under External libraries > Extendend definitions there is a NumPy folder so I guess that the installation goes well.

Asked By: Pickeroll

||

Answers:

In PyCharm go to

  1. File → Settings, or use Ctrl + Alt + S
  2. < project name > → Project Interpreter → gear symbol → Add Local
  3. navigate to C:Miniconda3envsmy_envpython.exe, where my_env is the environment you want to use

Alternatively, in step 3 use C:Miniconda3python.exe if you did not create any further environments (if you never invoked conda create -n my_env python=3).

You can get a list of your current environments with conda info -e and switch to one of them using activate my_env.

Answered By: mab

It seems that each project may have a separate collection of python libraries in a project specific computing environment. To get this working with numpy I went to the terminal at the bottom of the pycharm window and ran pip install numpy and once the process finished running the install and indexing my python project was able to import numpy from the line of code import numpy as np. It seems you may need to do this for each project you setup in numpy.

Answered By: Lucas Roberts

Go to

  1. ctrl-alt-s
  2. click "project:projet name"
  3. click project interperter
  4. double click pip
  5. search numpy from the top bar
  6. click on numpy
  7. click install package button

if it doesnt work this can help you:

https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

Answered By: Mert Cuhaci

Another option is to open the terminal at the pycharm & install it with pip

sudo pip install numpy
Answered By: IsaacE

I added Anaconda3/Library/Bin to the environment path and PyCharm no longer complained with the error.

Stated by https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001194720/comments/360000341500

Answered By: Azriel Tan

In general, the cause of the problem could be the following:

You started a new project with the new virtual environment. So probably you install numpy from the terminal, but it is not in your venv. So

  • either install it from PyCahrm Interface: Settings -> Project Interpreter -> Add the package

  • or activate your venv and -> pip install numPy

Answered By: Gehad

I have encountered problem installing numpy package to pycharm and finally figured out. I hope it would be helpful for someone having the same problem in installing numpy and other packages on pycharm.

Pycharm Setting :
Pycharm Setting

Go to File => Setting => Project => Project Interpreter. On this window select the appropriate project interpreter. After this, a list of packages under the selected project interpreter will be shown.
From the list select pip and check if the version column and the latest version column are the same. If different upgrade the version to the latest version by selecting the pip and using the upward triangle sign on the right side of the lists.
Once the upgrading completed successfully, you can now add new packages from the plus sign.

enter image description here

I hope this would be clear and useful for someone.

Answered By: Abdu
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.