0

Every time I download a package(like tensorflow, scipy, etc) from pip I need to manually change the project interpreter in Pycharm before I can import the package, which feels annoying. What's even worse is that I can easily execute import commands like import tensorflow in Python shell.

What I figured out so far is that even though all the downloaded packages are in 'C:\Python37\Lib\site-packages' and Pycharm does import automatically from Python37\Lib, it doesn't import from site-packages because dash symbol is invalid syntax.

Is it ok if I move packages directly under Lib so that all future Pycharm projects can use it, or there are better ways?

Jason
  • 15
  • 1
  • 5
  • What do you mean by "import by changing the project interpreter"? Are you talking about PyCharm recognizing the installation? – dalmago Oct 10 '19 at 16:36
  • You should be installing these packages into a virtual environment. Setup PyCharm so that the interpreter uses this virtual environment and you'll never have to change the settings in PyCharm. It's good practice (in my opinion) to have a separate virtual environment for each project you have. Installing the necessary libraries when needed. – SyntaxVoid Oct 10 '19 at 20:09
  • @SyntaxVoid so you mean I should only download packages to "venv" folder in my project folder? – Jason Oct 10 '19 at 22:34
  • What do you mean by download? The "normal" way of getting packages is to 1. Activate the environment you want it in. 2a. `python -m pip install package_name`, and then it is part of the environment. If you are downloading and manually running the `setup.py` file, then you should do (1) above, and then 2b. `python setup.py install` – SyntaxVoid Oct 10 '19 at 22:37
  • Also, it looks like you're using a lot of scientific python libraries... These are all included on the default installation of `anaconda`, which is an alternate python distribution. If you find yourself doing data analytics, plotting, lots of math stuff, then check out Anaconda: https://www.anaconda.com/distribution/ – SyntaxVoid Oct 10 '19 at 22:39

0 Answers0