I have miniconda3
installed and since I would like to have an environment with python version 3.3.0, I create it via
conda create -n "myenv" python=3.3.0
However when I activate the environment via
conda activate myenv
python has version 2.7.15 and path
/usr/bin/python
and ipython has python version 3.6.8 and path
/home/myname/.local/bin/ipython
I can access the correct python with python3
which is at
/home/myname/miniconda3/envs/myenv/bin/python3
however, ipython3
has python version 3.6.8 again.
conda install python=3.3.0
left the situation unchanged.
A solution would be to open IPython via
python3 -m IPython
however, while this works fine for python
here I get the error message
/home/myname/miniconda3/envs/myenv/bin/python3: No module named IPython
Is it possible to access with the commands python
and ipython
both python version 3.3.0 in that specific environment, i.e. not by setting an alias in the .bashrc
?
EDIT:
Turns out that this problem does not occur if you select version 3.3 instead of 3.3.0 together with @ilmarinen's answer
conda create -n "myenv" python=3.3 ipython
everything works fine and python
as well as ipython
result to version python 3.3.5
.
Anaconda uses a default environment named base and you cannot create a new (e.g. python 3.6) environment with the same name. This is intentional. If you want your base Anaconda to be python 3.6, the right way to do this is to install Anaconda for python 3.6.
This can be installed via conda with the command conda install -c anaconda python=3.7 as per https://anaconda.org/anaconda/python. Though not all packages support 3.7 yet, running conda update --all may resolve some dependency failures.
You need to install ipython as well into your given environment
conda create -n "myenv" python=3.3.0 ipython
The conda environments are prepended to your PATH variable, so when you are trying to run the executable "ipython", Linux will not find "ipython" in your activated environment (since it doesn't exist there), but it will continue searching for it, and eventually find it wherever you have it installed.
To create an environment named py33
with python 3.3.0, using the channel conda-forge and a list of packages:
conda create -y --name py33 python==3.3.0
conda install -f -y -q --name py33 -c conda-forge --file requirements.txt
conda activate py33
...
conda deactivate
Alternatively you can use
conda env create -f environment.yml
to use an environment.yml file instead of requirements.txt:
name: py33
channels:
- conda-forge
dependencies:
- python=3.3.0
- ipython
Use this command to remove the environment:
conda env remove -n py33
I had similar issue. And I could't find many useful discussions.
The problem for me was I have alias pointing python to miniconda python hardcoded in my shell config file when I execute conda init zsh
. Somehow the init process copies the alias and always reload that, thus overwrites the "correct" version.
After conda create -n py27 python=2.7
(my system default is 3.6), the version was correctly installed at miniconda3/envs/py27/bin/python
. But the activated evironment python was not pointing to it, as indicated by which python
,even if I deleted updated my shell config.
In the end it was solved by 'reverse' conda init (remove the generated conda function in .zshrc
), remove alias, and re-init.
I guess other shell is using the same mechanism.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With