图书馆在Spyder中可以正常工作,但在PyCharm中却不能 [英] Libraries work fine in Spyder but not in PyCharm

查看:448
本文介绍了图书馆在Spyder中可以正常工作,但在PyCharm中却不能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个库可以在Spyder中正常运行,但不能在PyCharm中运行.

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

import seaborn as sns
import matplotlib.pyplot as plt

在PyCharm中,我以为我可以单击文件">设置",然后将项目解释器"指向Python 3.6,这是我在Spyder中使用的,并且效果很好.还有其他需要重新设置的设置吗?或者,还有其他我想念的东西吗?最后,如果我需要一个新的库,请转到必要的库"Anaconda Prompt"和"pip install ...". PyCharm会一样吗?我最近安装了PyCharm,并试图更好地理解它.谢谢.

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.

推荐答案

Spyder(在anaconda中使用时)通常将使用默认的anaconda容器(例如/home/user/anaconda2/bin/python),或者在环境中工作时使用/home/user/anaconda2/envs/python3/bin/python.

这不一定与您的OS路径所指向的python相同.将pycharm配置为可与anaconda一起使用时,必须明确指向所需解释器的路径.

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.

可以通过以下方法检查来自spyder的解释器可执行文件的路径:

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

import sys

print(sys.executable)

设置正确的解释器后,对conda env的所有修改将与pycharm一起使用.

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

这篇关于图书馆在Spyder中可以正常工作,但在PyCharm中却不能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆