0

For example, I installed (pip install pandas) on terminal on MacBook. I could import pandas well in Idle, but when I imported pandas on Pycharm, there's red line below pandas, and it did not work. So, I went to preferences ->Project interpreter-> and then I installed pandas (by clicking + button). After that, everything worked.

My question is do I have to do that process whenever installing pip on terminal? installing pip on terminal is not enough ?

Kyle Leo
  • 13
  • 1
  • 3

1 Answers1

0

It is very common for Python developers to use multiple virtual environments for different projects as they might, e.g. want to install Python 3.8 for one project, but for another they're using libraries that don't yet support 3.8.

PyCharm allows you to choose, and even create, a virtual environment for each project. You control that for the project at the Project Interpreter screen that you already know. You don't have to use a different one for each one but you have that option.

Apparently the default environment that you used to install Pandas in Terminal is not the same as the default you chose in PyCharm. Now you know that. PyCharm also has its own terminal (click the Terminal tab at the bottom-left of the IDE) and if you use that to pip install it will do so into the environment that you are currently using within PyCharm.

If you're always working in PyCharm, you can get used to the idea of installing inside PyCharm for the sake of simplicity.

You might want to take some time and read the PyCharm documentation here as that goes into much greater detail that I can about how to use different types of virtual environments.

David Buck
  • 3,752
  • 35
  • 31
  • 35
  • Thank you so much, really appreciate it! – Kyle Leo Nov 28 '19 at 23:27
  • Just one more question. mentioned "the default environment that you used to install Pandas in Terminal is not the same as the default you chose in PyCharm" !! How can I make them the same default environment so that I do not have to do hassle? – Kyle Leo Nov 28 '19 at 23:28
  • I'd recommend that you learn to get used to the hassle. I, for example, use the Anaconda distribution which easily allows you to maintain multiple virtual environments. It's handy to, e.g. have one for code dojos where I might install any old library without worrying. It's part of working with Python. If you really want to, you can use the instructions here:https://stackoverflow.com/questions/33175827/what-version-of-python-is-on-my-mac to indentify where it is, then add that directory as an existing interpreter to Pycharm, but beware, it's quite possibly Python 2.7 which is nearly End of Life – David Buck Nov 28 '19 at 23:45