0

Really sorry if this is an elementary question, but I am having trouble selecting the appropriate project interpreter in PyCharm.

I go into Preferences and click on Project Interpreter, and I've tried selecting the following:

/usr/bin/python/ /usr/bin/python27/ /usr/bin/pythonw/

However, none of these paths seem to have knowledge of my libraries installed. For example, I have pandas installed. When I open idle it recognizes it perfectly when I import pandas as pd. But, when I try to run my script in PyCharm, it throws an import error.

What is the appropriate path to run my interpreter so that it has knowledge of all of my packages?
Or, is there a way to give it multiple paths to run an interpreter? Or, how do I find out what path the interpreter for idle is running with?

Thanks. I'm using Mac, OSX Yosemite.

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
makansij
  • 9,303
  • 37
  • 105
  • 183
  • The best way is to create a new `virtualenv` for the project then install whatever libraries you need in that - all of which you can do within PyCharm! – jonrsharpe Oct 28 '15 at 15:07
  • But then do I have to reinstall the libraries that I already have locally, on the virtual environment? – makansij Oct 28 '15 at 16:16
  • 1
    Yes, but it gives you a self-contained environment that you can easily allow other people to set up with e.g. `requirements.txt`. In fact, you could `pip freeze > requirements.txt` outside the virtual environment, trim it down to what you need and then use `pip install -r requirements.txt` inside the virtualenv to get it up to speed quickly. – jonrsharpe Oct 28 '15 at 16:18
  • I understand your point, but is there no way to keep it locally? I don't plan to share it any time soon. – makansij Oct 28 '15 at 18:24
  • Further, if I run it virtually, I have to manually select all of the libraries I need (which is a lot), even though I know that I already have them installed locally. There's gotta be an easier way. – makansij Oct 29 '15 at 00:16
  • It might be easier, but that might not be better. The idea that all of your projects are all going to use the same versions of all Python libraries looks good upfront, but hurts later. But back to your question. Is your point that you can do "$ /usr/bin/python" from the terminal and import your library successfully, but can't do it in PyCharm after selecting that as the project interpreter? That would indeed be unusual. If so, write a small script that prints sys.path when run from PyCharm. See if it is omitting what you think is the location of the Python libraries. – Paul Everitt Nov 02 '15 at 14:09

0 Answers0