How can I create a exclusively 32 bits conda environment? I tried:
set CONDA_FORCE_32BIT=1
conda create -n py310_32 python=3.10.5
But it didn't work.
Follwing commands will successfully get a 32-bit python. I suppose the main problem is the environment variable. You know windows is this. :(
conda create -n py27_32
conda activate py27_32
conda config --env --set subdir win-32
conda install python=2.7
useful links:
Using multiple Python engines (32Bit/64bit and 2.7/3.5)
How can I have two different environments within Anaconda? (both Python 3.7, one 32bit and one 64bit)
https://github.com/conda/conda/issues/1744
Related
I recently installed Anaconda in my Windows. I did that to use some packages from some specific channels required by an application that is using Python 3.5 as its scripting language.
I adjusted my PATH variable to use Conda, pointing to the Python environment of the particular program, but now I would like to use Conda as well for a different Python installation that I have on my Windows.
When installing Anaconda then it isn't asking for a Python version to be related to. So, how can I use Conda to install into the other Python installation. Both Python installations are 'physical' installations - not virtual in any way.
Uninstall the other python installation and create different conda environments, that is what conda is great at.
Using conda from your anaconda installation to manage packages from another, independent python installation is not possible and not very feasible.
Something like this could serve your needs:
Create one env for python 3.5 conda create -n py35 python=3.5
Create one env for some other python version you would like to use, e.g. 3.6: conda create -n py36 python=3.6
Use conda activate py35, conda deactivate, conda activate py36 to switch between your virtual environments.
I have a python 3.4 environment with very specific packages installed. Is there a straight forward way to create an anaconda environment will all the same packages without creating a python environment then manually installing the packages. e.g..
conda create -n myenv python=3.4
conda activate myenv
conda install beautifulsoup4==4.6.1
I'd like to do this as i want to share a python script and make it as easy as possible for others to run it.
These are all the packages installed in my python3.4 environment
'altgraph==0.16.1',
'asn1crypto==0.24.0',
'beautifulsoup4==4.6.1',
'certifi==2018.4.16',
'cffi==1.11.5',
'chardet==3.0.4',
'configargparse==0.13.0',
'cryptography==2.3',
'defusedxml==0.5.0',
'dis3==0.1.3',
'future==0.17.1',
'h5py==2.8.0',
'idna==2.7',
'jira==2.0.0',
'macholib==1.11',
'numpy==1.15.3',
'oauthlib==2.1.0',
'pbr==4.2.0',
'pefile==2018.8.8',
'pycparser==2.18',
'pyinstaller==3.4',
'pyjwt==1.6.4',
'pyqt4==4.11.4',
'pywin32-ctypes==0.2.0',
'pywin32==220',
'regex==2018.07.11',
'requests-oauthlib==1.0.0',
'requests-toolbelt==0.8.0',
'requests==2.19.1',
'six==1.11.0',
'urllib3==1.23',
'xmltodict==0.11.0'
conda-env is your friend:
conda-env export -n orig > orig.yml
where orig is the name of the environment you want to clone, followed by
conda-env create -n new -f=orig.yml
where new is the new name of the copy. The file orig.yml contains everything about the environment you want to copy: dependencies, installed packages incl. version, and such.
I installed the latest Anaconda and installed it with default values.
After that, I tried which python and it's giving me correct python paths for Anaconda5.1 Python2.7 versions ~/anaconda2/bin.
Now when I create a virtual environment using the following command:
conda create -n new_env python=2.7 opencv numpy pandas
&
source activate new_env
When I do which python now I get the new virtual environment python ~/anaconda2/envs/new_env/bin/python which is good. But when I do which conda I get the base anaconda conda ~/anaconda2/bin/conda not the virtual environment conda path. In previous versions, it wasn't like this.
Am I missing something here?
p.s. I tried with Anaconda5.1 for Python3.6 also, the same result.
I want to create an anaconda python environment with all of the packages that Continuum includes in its default Anaconda installer. Based on some internet search I used the following command:
conda create -n env_full python=3
However, only handful of packages would be installed. Please see the screen shot.
Kindly guide me to use correct commands.
Right now I am trying to do this on a desktop computer, but I would like to apply the same principles to the cluster facility.
To install all of the packages that Continuum includes in its default Anaconda installer, the simplest command is this:
conda create -n env_full anaconda
This will install the latest version of the anaconda package set, as compiled for your default version of Python (the one you used to install Anaconda originally). If you'd like to create an environment with a different version of Python, then just add that to the command line; e.g.
conda create -n env_full anaconda python=2.7
conda create -n env_full anaconda python=3.5
Anaconda ships with a root env, this is named as base. You can use this as it is or clone a new environment from it.
if you just want a environment with all the packages for day to day then you can use the base enviornment itself.
you can list the all available conda env on your machine as follows
conda info --env
you will see a enviornment name base, activate it to use it
source activate base
You can verify all the packages available in the env with following command ( This work with any env created with conda)
conda list -n base
As I said above if you want a different env then you can clone base using following command
conda create --name <env_name> --clone base
When I run this command:
conda create -n env_full anaconda>
I get a PackageNotFoundError. So I create a simple environment:
conda create -n env_full
and use this command to install all the anaconda default packages:
conda install anaconda
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.
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.
Setting the Subdirectory Constraint
Conda has a configuration variable subdir that can be used to constrain package searching to platforms (e.g., win-32). I think the most reliable procedure is to create the empty environment, set its subdir, then proceed with the (constrained) installations. For example,
win-32, Python 2.7
conda create -n py27_32
conda activate py27_32
conda config --env --set subdir win-32
conda install python=2.7
win-64, Python 3.7
conda create -n py37_64
conda activate py37_64
conda config --env --set subdir win-64
conda install python=3.7
Alternatively, if you need to, for example, create an environment from a YAML file, but want a win-32 platform, one can use the CONDA_SUBDIR environment variable:
set CONDA_SUBDIR=win-32
conda env create -f env.yaml -n my_env_32
set CONDA_SUBDIR=
conda activate my_env_32
conda config --env --set subdir win-32
The nice thing about this procedure is the variable will now always be set whenever activating the environment, so future changes to the environment will remain within the specified subdirectory.
Ad Hoc Constraints
It is also possible to specify the platform in the --channel|-c argument:
conda install -c defaults/win-32 --override-channels python=3.7
Here the --override-channels is required to ensure that only the provided channel(s) and subdirectory (win-32) is used.
However, setting the subdir on the whole env is likely a more reliable practice.
YAML Constraints
It is also possible to use subdir specifications in a YAML environment definition. However, this is less reliable (see below and comments). For example,
py37_win32.yaml
name: py37_win32
channels:
- defaults/win-32
dependencies:
- python=3.7
#Bicudo has tried this and confirms it works, but notes that it does not set any environment-specific constraints on future updates to the environment. Additionally, #Geeocode pointed out that the default subdir can still leak in, which is likely due to conda env create still having access to the global channels configuration during solving (there is no equivalent --override-channels flag for conda env create). Hence, it would be good practice to still set the subdir before and after environment creation, e.g.,
set CONDA_SUBDIR=win-32
conda env create -f py37_win32.yaml
set CONDA_SUBDIR=
conda activate py37_win32
conda config --env --set subdir win-32
Alternatively, beginning with Conda v4.9, one can also specify environment variables as part of the YAML. That is, one can effectively define an environment's CONDA_SUBDIR value at environment creation:
py37_win32.yaml
name: py37_win32
channels:
- defaults/win-32
dependencies:
- python=3.7
variables:
CONDA_SUBDIR: win-32
I just wanted to add to Mike Mullers answer, as I also wanted my IPython to switch between 32 bit and 64 bit.
After setting up the 32bit or 64bit environment. Use the following commands
pip install ipykernel
to install ipykernel on this env. Then assign it with:
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
here myenv is the name of your new environment. See this page here for further details on switching kernels - http://ipython.readthedocs.io/en/stable/install/kernel_install.html
(now in conda win64 - python64 activate env)
set CONDA_SUBDIR=win-32
conda install python
you will see
The following packages will be SUPERSEDED by a higher-priority
channel:
ca-certificates anaconda/pkgs/main/win-64::ca-certifi~ -->
anaconda/pkgs/main/win-32::ca-certificates-2021.7.5-h9f7ea03_1
openssl anaconda/pkgs/main/win-64::openssl-1.~ -->
anaconda/pkgs/main/win-32::openssl-1.1.1k-hc431981_0 python
anaconda/pkgs/main/win-64::python-3.9~ -->
anaconda/pkgs/main/win-32::python-3.9.5-h53c7b84_3
Proceed ([y]/n)?
just type "y"
this setting is saved in file "\anaconda\envs\ you env \ .condarc"