2

So I am quite new to Python and only have completed like 2 or 3 projects, but every module, like bs4, had to be installed via the IDEs terminal every time I started a new project. If I didn't do that, the IDE told me that the modules I tried to import aren't installed.

quamrana
  • 37,849
  • 12
  • 53
  • 71
Mariot
  • 45
  • 1
  • 6
  • Presumably, because *you* are using a different interpreter/virtual environment for each project... which is generally considered the best practice anyway – juanpa.arrivillaga Jun 28 '21 at 17:04

3 Answers3

2

You can create a file with all your installed modules.

If you have pip already installed, just type in the IDE terminal:

pip freeze > requirements.txt

Now you have a file with all your modules and their versions. Next time you want to install all of them with a single command, move your requirements.txt file to your script path and type in the terminal:

pip install requirements.txt

  • 1
    This is generally **not** the recommended approach, rather, unfortunately, dependencies should be handled "manually"... in any case, this doesn't really answer the quesition – juanpa.arrivillaga Jun 28 '21 at 17:11
0

You can select project interpreter.

Go to SettingsPython Interpreter. Select your environment. If you are creating a new project, use base environment instead of creating a "virtual environment".

Edit As @juanpa.arrivillaga pointed out, this may not be the preferred way. If you are installing dependencies, make sure you have a new conda environment (rather than using base environment) dedicated to that project. So that, if things go south, you can delete that environment and create new one.

Ibrahim Berber
  • 842
  • 2
  • 16
0

When you install a package via pycharm in a project, they are most likely being put into a virtual env, like a sandbox. This is so you don't get conflict with packages down the road from installing tons and tons of packages. Checkout this answer, which i think will help you out with what your trying to avoid with reinstalling packages over and over.

Josh
  • 318
  • 2
  • 8