使用多个 Python 引擎(32Bit/64bit 和 2.7/3.5) [英] Using multiple Python engines (32Bit/64bit and 2.7/3.5)

查看:32
本文介绍了使用多个 Python 引擎(32Bit/64bit 和 2.7/3.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 Python 用于科学应用程序,经过一些研究后决定我将使用 Anaconda,因为它捆绑了大量软件包,并且通过 cmd 使用 conda install 添加新模块很容易.

I would like to use Python for scientific applications and after some research decided that I will use Anaconda as it comes bundled with loads of packages and add new modules using conda install through the cmd is easy.

我更喜欢使用 64 位版本以获得更好的 RAM 使用和效率,但是还需要 32 位版本,因为有些库是 32 位的.同样,我更喜欢使用 Python 3.5,因为那是未来和事情的发展方向.但是大量的库仍然是 2.7,这意味着我需要两者.

I prefer to use the 64 bit version for better RAM use and efficiency but 32bit version is needed as well because some libraries are 32bit. Similarly, I prefer to use Python 3.5 as that is the future and the way things go. But loads of libraries are still 2.7 which means I need both.

我必须安装 4 个版本的 Anaconda(64 位 2.7、64 位 3.5、32 位 2.7、64 位 3.5).每个版本大约 380MB.我的目标是使用 Jupyter notebook 和 Spyder 作为 IDE.我不得不在需要时在版本之间切换.我遇到了冲突的库、路径问题和各种奇怪的问题.

I have to install 4 versions of Anaconda (64bit 2.7, 64bit 3.5, 32bit 2.7, 64bit 3.5). Each version is about 380MB. I am aiming to use Jupyter notebook and Spyder as the IDE. I had to switch between versions when required. I had conflicting libraries, path issues and all sorts of weird problems.

所以,我打算从头开始进行全新安装.我想知道是否有更明智的方法来处理这个问题.如果重要的话,我现在使用 Windows 7 64 位.

So, I am planning to do a clean install from scratch. I would like to know if there is a more sensible way to handle this. I use Windows 7 64 bit for now if that matters.

推荐答案

确保设置正确的环境变量 (https://github.com/conda/conda/issues/1744)

Make sure to set the right environmental variables (https://github.com/conda/conda/issues/1744)

为 32 位 Python 2.7 创建一个新环境:

Create a new environment for 32bit Python 2.7:

set CONDA_FORCE_32BIT=1
conda create -n py27_32 python=2.7

激活它:

set CONDA_FORCE_32BIT=1
activate py27_32

停用它:

deactivate py27_32

为 64 位 Python 3.5 创建一个:

Create one for 64 bit Python 3.5:

set CONDA_FORCE_32BIT=
conda create -n py35_64 python=3.5

激活它:

set CONDA_FORCE_32BIT=
activate py35_64

最好将激活命令写入批处理文件中,这样您只需键入一个命令,并且不会忘记设置正确的 32/64 位标志.

The best would be to write the activation commands in a batch file so that you have to type only one command and cannot forget to set the right 32/64 bit flag.

更新

您不需要为此安装完整的 Anaconda 发行版.Miniconda 就够了:

You don't need to install a full Anaconda distribution for this. Miniconda is enough:

这些 Miniconda 安装程序包含 conda 包管理器和 Python.安装 Miniconda 后,您可以使用 conda 命令安装任何其他软件包并创建环境等....

These Miniconda installers contain the conda package manager and Python. Once Miniconda is installed, you can use the conda command to install any other packages and create environments, etc. ...

安装程序有两种变体:Miniconda 基于 Python 2,Miniconda3 基于 Python 3.注意选择安装哪个 Miniconda 只影响 root 环境.无论您安装哪个版本的 Miniconda,您仍然可以同时安装 Python 2.x 和 Python 3.x 环境.

There are two variants of the installer: Miniconda is Python 2 based and Miniconda3 is Python 3 based. Note that the choice of which Miniconda is installed only affects the root environment. Regardless of which version of Miniconda you install, you can still install both Python 2.x and Python 3.x environments.

我建议您使用 Miniconda3 64 位作为根环境.

I would recommend you to use Miniconda3 64-bit as your root environment.

您以后可以随时安装完整的 Anaconda:

You can always install a full Anaconda later with:

conda install anaconda

请注意,它可能会降级您之前在活动环境中安装的某些软件包.

Note that it might downgrade some of your previously install packages in your active environment.

这篇关于使用多个 Python 引擎(32Bit/64bit 和 2.7/3.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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