I am creating a conda env with conda create -n env python==3.8. But when I activate it and do python -V, it shows Python 3.6.8. Outside of the activated conda env python -V outputs Python 3.8.13.
I've gone through similar issues but none of the advice helps. I am desperate and mad :D
How is your Anaconda's Version?
1.
You must use "Anaconda Prompt (Anaconda3)" into command line,
and try "conda update --all", update your Anaconda.
2.
Did you install Python 3.6.X in your computer and update it?
If yes, this is why you at Outside see the python -V =3.6.13
Related
I am trying to create a new conda Python 2.7 environment.
For this purpose I am typing this in terminal:
conda create -n my_env_name python==2.7
After activating created environment (conda activate my_env_name) and checking Python version (python --version) I am getting Python 3.10.2
No matter which Python version I am trying to use in the new environment I am always getting Python 3.10.2 answer when checking the Python version.
Any idea what is wrong and how to solve this?
(I am working on iMAC, Chip Apple M1, macOS Monterey 12.1)
(After doing the same on my old machine everything works fine and after checking the Python version in a newly created environment I am getting Python 2.7.18.)
Here are some additional info.
When env is activated commands:
which python gives- /opt/local/bin/python
type python gives- python is /opt/local/bin/python
echo $PATH gives- /opt/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/uros/Desktop/iraf-main/unix/hlib/ecl.sh://Users/uros/.iraf/bin:/opt/anaconda3/envs/py27/bin:/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin
When env is not activated commands:
which python gives- /opt/local/bin/python
type python gives- python is /opt/local/bin/python
echo $PATH gives- /opt/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/uros/Desktop/iraf-main/unix/hlib/ecl.sh://Users/uros/.iraf/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin
After running conda list output is this:
I had the same problem with my M1 Mac.
As it turns out when working with python versions below 3.8 according to this post here there is no support for running osx-arm64. They go into the details on how to fix this.
You can also follow this blog post from Danny Cunningham How to Manage Conda Environments on an Apple Silicon M1 Mac
Manage both ARM64 and x86 Python environments using conda
in your case it should be something like:
CONDA_SUBDIR=osx-64 conda create -n my_env_27_x86 python=2.7
I hope this helps,
TL;DR With conda3, specify the Python 2.7 version fully, e.g., 2.7.18.
When I tried to reproduce your command in my own conda3 environment, I got this error:
PackagesNotFoundError: The following packages are not available from current channels:
- python==2.7
However, when I specified the version of Python 2.7 fully, it worked for me:
conda create -n p27 python==2.7.18
conda activate p27
python --version
shows that Python 2.7.18 is the default Python in that environment.
Alternative: use conda2
With Anaconda3/Miniconda3, the default Python will be Python 3.x, whereas with Aanconda2/Miniconda2, the default Python would be Python 2.7.x. On your old machine, you might have had conda2 installed, which would explain why it worked.
Thanks to #FlyingTeller for pointing out conda2 is not necessary, though.
I had a conda environment in my PC and yesterday I updated dependencies in that env using the command conda update --env. But when I tried to find Anaconda Prompt in the windows search bar today, that is not showing. I search all the questions regarding this problem on the SO, but many answers were not helpful or with broken links. I'm somewhat new to conda, therefore any helpful suggestion is highly appreciated.
You can toggle between the conda environment as such:
$ conda activate # this will enter the conda shell
$ conda deactivate # this will leave the conda shell
Let me know if you need any more help.
I currently have python3 set as my default python version but I'd like to be able to switch back to python2 for certain things so I created a conda environment with the following command:
conda create -n py2 python=2.7
and then activated it with:
source activate py2
but when I do:
python --version
I still get
Python 3.6.8
What am I doing wrong here? I'm trying to download a conda package this is only python2 compatible but despite being in a python2 environment, it keeps telling me my python version is incompatible.
You might be running into the issue where you have multiple environments on top of one another.
Try running:
conda deactivate
multiple times in order to exit from all of the environments. Then run:
condo activate py2
It makes me crazy, In anaconda I create the environment with the defualt iterpreter python3.4 Next I install pytorch 0.4.1
conda install pytorch=0.4.1 cuda80 -c pytorch
After this I found that the pytorch was installed in python3.6!
And the environment defualt interpreter is chaged from python3.4 to python3.6.
I am very confused what happend ? How shoud I fix it back? change defualt python back to python3.4? Hope some one could help me.
The commands I typed in are as follows:
conda create -n pointgen python=3.4 ipykernel
source activate pointgen
conda install pytorch=0.4.1 cuda80 -c pytorch
Thats all. What Novak said is right, there is remaining question is how could I manually change the python version from 3.6 back to 3.4, is there any config file I can deal with?
As you can see here there is no version of pytorch for python3.4... The default version of pytorch is for python3.6 and that is the version you installed installed. In the process anaconda prompts you that it will have to upgrade/downgrade some package versions and there is probably the the line in which it says it will upgrade python to 3.6
After activating my anaconda Python 3.6 environment with
source activate py36
if I type
python
I go into python 3.6, as expected. But if I type
ipython
I go into an ipython environment based python 3.5.5, which is the same python version I get using
source activate base
and then
python
How can I get into an ipython environment using my anaconda-supplied python 3.6 interpreter? I have updated my anaconda environment with
conda update anaconda
and
conda update conda
Doing so does not help.
EDIT:
I hadn't realized that I had to install ipython separately for the python 3.6 environment; I'd thought it was a default part of anaconda. So
conda install ipython
after
source activate py36
did the trick. It doesn't seem optimal that after activating a particular environment, ipython may bring up a completely different anaconda-based environment. I'd prefer it to simply cause a "command not found" error. Bringing up the wrong environment without making it very obvious that that is happening could lead to confusion or problems.
I hadn't realized that I had to install ipython separately for the python 3.6 environment; I'd thought it was a default part of anaconda. So
conda install ipython
after
source activate py36
did the trick.
Have you done hash -r since entering the conda environment? Bash can cache paths to executables, so sometimes it doesn't use the one reported by which. Running hash -r resets the cache
Maybe you need also to update ipython conda update ipython