简体   繁体   中英

How to run a .py from terminal with a pycharm environnement

I'm a begginer i don't really know how is working Pycharm.

I'm trying to start a.py from the terminal: psyko@psyko-desktop:~/Python/Neural Network/FFNN$ python3.6 Build.py Traceback (most recent call last): File "Build.py", line 1, in <module> from stuff.gradient_descent import gradient_descent File "/home/psyko/Python/Neural Network/FFNN/stuff/gradient_descent.py", line 1, in <module> import numpy as np ModuleNotFoundError: No module named 'numpy' psyko@psyko-desktop:~/Python/Neural Network/FFNN$

When I run this code into pycharm it works because numpy is downloaded. So i want to use the same environnement but on the terminal.

Plus whenever I start a new project i have to download again numpy... how to change that?

Most probably Pycharm uses a virtual environment. The name of the virtual environment should be env or venv . You need to switch that environment. Find out it's name and switch to it.

Let's suppose your virtual environment name: venv . You can activate it via running below command in the cmd:

For windows:

venv\Scripts\activate.bat

For Linux:

source venv/bin/activate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM