1

On Ubuntu I have python 3.6.9

I created new project using PyCharm, into project folder there is venv folder. When I open venv folder in terminal and do:

python3
import numpy

It works, no any error.

But when I create some file in that venv folder using PyCharm, and try in this file:

import numpy 

then I get ModuleNotFoundError: No module named 'numpy' error.

Why can't import module into file? module obviously installed because I can import that using terminal (folder is same for both cases).

What is my mistake ?

3
  • Do you use a different version of python on PyCharm ? Commented Sep 27, 2020 at 20:36
  • @SurajSubramanian - in pycharm import sys print(sys.version) gives: 3.6.9 Commented Sep 27, 2020 at 21:25
  • @SurajSubramanian - in terminal exactly same version Commented Sep 27, 2020 at 21:26

3 Answers 3

1

Pycharm uses virtual environments for serving modules, so you will have to download the package from either the GUI or by activating the virtual environment in the terminal and then doing the pip install.

if you want to do it from the GUI you can check the official tutorial. (Working and tested)

To do it manually, first to activate the environment in linux go wherever the venv folder is and type source venv/scripts/activate (to activate) and then you'll be able to do pip install numpy. (Not tested but it should work)

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, it seems I missed virtual environment activation, after that, imported module into file, without problem
0

Could you share your Pycharm configuration? Some extra steps are needed in Pycharm to configure venv, otherwise it will just take your normal interpreter site-packages.

Take a look at the Pycharm help page: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html#existing-environment

Comments

0

looks like you need to install numpy through pip3. Also, check which version of python is running in pycharm.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.