Libraries work fine in Spyder but not in PyCharm

2019-08-03 08:38发布

问题:

I have a couple libraries that run fine in Spyder but not in PyCharm.

import seaborn as sns
import matplotlib.pyplot as plt

In PyCharm, I thought I could click File > Settings and point the Project Interpreter to Python 3.6, which is what I'm using for Spyder, and that works fine. Is there some other setting that needs to be re-pointed? Or, is there something else that I'm missing? Finally, if I ned a new library, I go to the 'Anaconda Prompt' and 'pip install ...' the necessary library. Will this be the same for PyCharm? I recently installed PyCharm and I'm trying to understand it better. Thanks.

回答1:

Spyder (When used thru anaconda) will usually use either the default anaconda bin, such as /home/user/anaconda2/bin/python, or when working from an env, /home/user/anaconda2/envs/python3/bin/python.

This is not necessarily the same python as your OS path points to. When configuring pycharm to work with anaconda, you must explicitly point to the path of the wanted interpreter.

Checking the path for your interpreter executable from spyder can be done by:

import sys

print(sys.executable)

When setting the right interpreter all your modification to the conda env will be working with pycharm.