让PyCharm认识Anaconda的SciPy [英] Getting PyCharm to recognize Anaconda's SciPy

查看:167
本文介绍了让PyCharm认识Anaconda的SciPy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用PyCharm IDE(在Mac OSX Lion计算机上)内部的SciPy库. SciPy网站写道,Mac用户最简单的安装方法是安装Anaconda(或等效发行版).我使用了Anaconda安装程序,它在我的主文件夹中创建了anaconda目录,在其中找到包含所需软件包的lib/python2.7/site-packages目录.但是,PyCharm并不了解所有这些情况,并且SciPy import语句仍未解决.

I need to use the SciPy libraries inside the PyCharm IDE (on a Mac OSX Lion machine). The SciPy website writes that the simplest installation method for Mac users is to install Anaconda (or an equivalent distro). I used the Anaconda installer, and it created an anaconda directory in my home folder, where I find a lib/python2.7/site-packages directory with the required packages. However, PyCharm is not aware of all this and the SciPy import statements remain unresolved.

然后我的问题是如何使PyCharm与Anaconda一起使用?

My question is then how to make PyCharm work with Anaconda?

推荐答案

我仍然对Python生态系统和PyCharm表示满意,因此请一言以蔽之,但是在

I'm still coming to terms with the Python ecosystem and PyCharm, so take the following with a grain of salt, but after reading up a bit, I thought I'd write a detailed explanation.

在安装过程中,Anaconda将默认的Python解释器更改为〜/anaconda/bin/python.该解释器配置了sys.path,默认为〜/anaconda/lib中的库.像python的pip这样的软件包管理器使用运行它们的解释器来确定安装软件包的路径,因此,在安装Anaconda之后,所有通过pip或其他方法安装的软件包都将放置在〜/anaconda/lib内部.即,即使不使用virtualenv之类的工具,每个Python解释器都有自己的生态系统,并且使用不同的解释器运行pip会将软件包安装到不同的目录中.

During installation, Anaconda changes the default Python interpreter to ~/anaconda/bin/python. This interpreter is configured with a sys.path that defaults to the libraries in ~/anaconda/lib . Package managers like python's pip use the interpreter that's running them to determine the path in which to install packages, so after Anaconda is installed, all packages installed via pip or other methods will be placed somewhere inside ~/anaconda/lib. i.e. even without using something like virtualenv, every Python interpreter has its own ecosystem and running pip with different interpreters will install packages into different directories.

PyCharm在Project Settings-->Project Interpreter-->Python Interpreters屏幕中处理所有这一切.为了使PyCharm知道Anaconda的发行版,您需要将Anaconda python解释器添加到Project Interpreter-->Python Interpreters列表中,并将其设置为项目的默认值.然后,PyCharm将找到Anaconda的解释器生态系统(〜/anaconda/lib)中安装的所有软件包,并在下面窗格的packages下列出它们.它还会提示您为该解释器安装setup_tools和pip,完成后,您将能够使用下部窗格中的install按钮向Anaconda生态系统添加更多软件包.

PyCharm handles all this in the Project Settings-->Project Interpreter-->Python Interpreters screen. To make PyCharm aware of the Anaconda distribution, you need to add the Anaconda python interpreter to the Project Interpreter-->Python Interpreters list and make it the default for the project. PyCharm will then locate all packages installed in Anaconda's interpreter ecosystem (~/anaconda/lib) and list them under packages in the lower pane. It will also prompt you to install setup_tools and pip for that interpreter, and once you do that you'll be able to use the install button in the lower pane to add more packages to the Anaconda ecosystem.

一旦添加了Anaconda解释器,您还可以使用上方窗格工具栏中的virtualenv按钮创建一个继承自Anaconda解释器环境的virtualenv.这样,您可以以不会影响全球Anaconda发行版的方式安装新软件包.

Once you've added the Anaconda interpreter, you can also use the virtualenv button from the toolbar on the upper pane to create a virtualenv that inherits from the Anaconda interpreter's environment. That way you can install new packages in a way that would not affect the global Anaconda distribution.

这篇关于让PyCharm认识Anaconda的SciPy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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