Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using multiple Python engines (32Bit/64bit and 2.7/3.5)

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.

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.

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.

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.

like image 467
rmf Avatar asked Nov 14 '15 14:11

rmf


People also ask

Can I have both 32 and 64-bit Python?

There are APIs to access the cross bitness nodes but that is outside the scope of this question. So to summarize, windows intelligently handles 32 and 64 bit applications by splitting the node which will allow 32 bit extensions to transparently access the 32 bit Python Installation.

Should I use 32-bit or 64-bit Python?

32-bit Python, and 32-bit apps generally, can access only 4GB of memory at a time. 64-bit applications don't have this limit, hence many data analysis and machine learning tools for Python work best in 64-bit incarnations. Some are available only in 64-bit versions.

How do I know if my Anaconda is 32 or 64-bit?

Linux Operating Systems: Scroll to the "Anaconda for Linux" section. Look in the column with Python 3.5. You can look here for how to determine your version 32-bit or 64-bit.


1 Answers

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

Create a new environment for 32bit Python 2.7:

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

Activate it:

set CONDA_FORCE_32BIT=1 activate py27_32 

Deactivate it:

deactivate py27_32 

Create one for 64 bit Python 3.5:

set CONDA_FORCE_32BIT= conda create -n py35_64 python=3.5 

Activate it:

set CONDA_FORCE_32BIT= activate py35_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.

UPDATE

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

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. ...

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.

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

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.

like image 186
Mike Müller Avatar answered Oct 08 '22 21:10

Mike Müller