I am a relatively new user of PyCharm/python, and was looking for advice about how to efficiently install packages. I have made several separate 'projects' which have small amounts of code, but all have similar packages installed. Some of these packages take up quite a lot of disc space (e.g. tensor flow is taking up 1GB), and seem to have been installed separately for each project. Is there an easy way to make sure multiple projects have access to these package files without installing them multiple times? Thanks

see as described above

1

There are 1 best solutions below

0
Vojtěch Chvojka On

I would first like to recommend two ways of doing that just with python. It will work for PyCharm, but also without it.

  1. You could just use one venv for all projects.
  2. If that is not suitable (f.e. projects requiring a different versions of some packages) You could use the PYTHONPATH environment variable. Simply add a path to the module to it before running your script.
  3. Alternatively, you could create *.pth file in your venvs. Search for it here.

The way to do that in PyCharm could be reusing a single venv for multiple projects.

  1. For existing projects, go to File > Settings > Project: ... > Python Interpreter and select the existing interpreter.
  2. For new projects, on Create Project window, in the section Python Interpreter: ... select Previously configured interpreter and choose the existing interpreter.