OS X-在anaconda和自制Python环境之间做出选择 [英] OS X - Deciding between anaconda and homebrew Python environments

查看:143
本文介绍了OS X-在anaconda和自制Python环境之间做出选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X上广泛使用Python,用于数值应用程序和Web开发(大致相等).我检查了最近在笔记本电脑上安装的Python的数量,很震惊地发现四个:

I use Python extensively on my Mac OS X, for both numerical applications and web development (roughly equally). I checked the number of Python installations I had on my laptop recently, and was shocked to find four:

Came with Mac OS X:
/usr/bin/python
Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin

Installed via Homebrew
/usr/local/bin/python
Python 2.7.10 (default, Jul 13 2015, 12:05:58)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin

Installed via Anaconda/Miniconda
~/anaconda/bin/python
Python 2.7.10 |Anaconda 2.3.0 (x86_64)| (default, Oct 19 2015, 18:31:17)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

Came with the downloaded .pkg from python.org
/System/Library/Frameworks/Python.framework/Versions/Current/bin/python
Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin

我决定统一所有这些,并使用conda.我删除了Homebrew版本和Python.org下载(保留主系统一个). Conda非常适合数值计算,因为我可以在根环境中安装Jupyter/Numpy/Pandas,而不必为每个项目都安装virtualenvs.

I decided to unify all of this, and use conda. I removed the Homebrew version and the Python.org download (kept the main system one). Conda is great for numerical computing, because I can install Jupyter/Numpy/Pandas in the root environment, and not have to bother install virtualenvs for every project.

但是现在我的整个Web开发工作流程都搞砸了.我的virtualenvs都不起作用,因为显然不应将conda和virtualenv一起使用.我试图从requirements.txt文件创建conda环境.我与django一起使用的一个软件包是"markdown_deux",它在Conda存储库中不可用.我研究了构建方法,但是创建食谱需要很多工作(创建YAML文件等).

But now my entire web development workflow is messed up. None of my virtualenvs work, since apparently one's not supposed to use conda and virtualenv together. I tried to create conda environments from the requirements.txt file. One package I was using with django was "markdown_deux", which is not available in the Conda repo. I looked at ways of building it, but creating a recipe takes a lot of effort (create YAML file, etc..)

有人为此找到一个好的妥协吗?我正在考虑回到一般使用的自制版本,并写一个别名以根据需要将路径更改回conda版本.尽管这还需要跟踪我现在正在使用的是哪个..

Has anyone found a good compromise for this? I'm thinking of going back to the homebrew version for general use, and writing an alias for changing the path back to the conda version as necessary. Though this will also require tracking which one I'm using now..

推荐答案

我将Homebrew Python用于我的所有项目(数据科学,某些Web开发).

I use Homebrew Python for all my projects (data science, some web dev).

Conda没什么特别的,您可以将pip自制技术组合在一起使用相同的程序包.实际上,它甚至更好,因为您可以更好地控制安装内容.

Conda is nothing fancy, you can have the same packages by hand with a combination of pip and Homebrew science. Actually, it is even better because you have more control on what you install.

仅在进行Web开发时才能使用virtualenvs.对于数值应用程序,您可能一直希望拥有最新版本的软件包.

You can use your virtualenvs only when you do web development. For the numerical applications you will probably want to have the latest versions of your packages at all times.

如果要使用pip一次更新所有软件包,可以使用以下命令:

If you want to update all your packages at once with pip, you can use this command:

sudo -H pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 sudo -H pip install -U

这篇关于OS X-在anaconda和自制Python环境之间做出选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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