How to change python version in Anaconda? - python

I am trying to get into deep learning. I installed Anaconda to use jupyter and generally not to care about installing all of those packages like matplotlib etc myself. But I cannot install tensorflow as it works only with Python 3.4, 3.5, or 3.6 but I have 3.7. After I read about it I installed python 3.6.8. I uninstalled Anaconda and installed it again, nothing changed. After that, I used this command
conda install python=3.6.8
to presumably install python 3.6.8 for it (I found this solution somewhere on the web). The command worked but didn't change anything. Please help

A better (recommended) alternative is to create a virtual environment of the desired Python version and then use that environment to run Tensorflow and other scripts.
To do that, you can follow the instructions given here.
BUT, if you don't want to create a separate environment, then conda install python=<version> should do.
OR (not recommended) you can download the "latest" Anaconda installer with your required Python version bundled.
Source

Sometime command is not working as expected I was also facing same issue when I
used this command.
conda install python=<version>
then I have changed the Python version with the help of anaconda Navigator. I have create new enviornment and follow below instruction=>
In Navigator, click the Environments tab, then click the Create button. The Create new environment dialog box appears.
In the Environment name field, type a descriptive name for your environment.
3.In the Packages list select “Python” and in the Python version list select the version you want to use.
4.Click the Create button.
5.Navigator creates the new environment and activates it, as shown by the highlighted green bar. All actions take place in the active environment.
for more details please go through this link =>
https://docs.anaconda.com/anaconda/navigator/tutorials/use-multiple-python-versions/

By default, the conda environment will use the python version 3.7, since you installed Anaconda with python3.7.
You would need to create a symbolic link to the new version of the python (in your case python3.6.8) using
ln -s ~/anaconda3/bin/<python3.6.8>
(you may need to replace 'python3.6.8' with the appropriate file name).
Another, better way would be to create a new environment in conda and then use python3.6.8 as you would like. Follow steps at https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands to create an environment.
For python3.6.8, run the following command:
conda create -n <myenv> python=3.6.8
(replace 'myenv' with the name of your new environment)
After that, activate the environment with :
conda activate <myenv>

This is a bug of the macOS 10.14.6. I degrade the python version from 3.7.4 to 3.7.0 in Anaconda and it works. Here I share my solution. I solve this question in other website. Check the answer by clicking here(https://www.udemy.com/course/the-python-mega-course/learn/lecture/4775342#questions/11049798).

You just can change the python version by creating a new environment in anaconda.
It will ask for the python version when you create an environment

The most pain-free approach that worked for me was to install the legacy version of Anaconda. If you want Python 3.6 as default, I recommand downloading Anaconda 5.2.0 which was the last version to use Python 3.6 in base environment as default. (Legacy versions can be found here.)
If you also want the latest version of Anaconda, there is an easy way. With Anaconda 5.2.0 installed, you can actually update to newer versions of Anaconda by
conda update anaconda
which will try to update all your packages except keepping Python at 3.6.x.

Related

How to change python version in r-reticulate environment?

I would like to upgrade my python version in my r-reticulate environment. First I activate the right environment like this:
conda activate /Users/quinten/Library/r-miniconda/envs/r-reticulate
Let's check the python version:
python3 --version
Python 3.7.11
So I installed the newest python version for macOS which is 3.11.1. After that, I tried to change the Python version like described here (How to change Python version of existing conda virtual environment?) using this:
conda install python=3.11
This was successfully installed, but when I check again the version python3 --version it still returns 3.7.11. So I was wondering if anyone knows how to change the python version in an r-reticulate environment? I would like to use this in ‘Quarto’.
One shouldn't need a system-level Python - it really only complicates working with Conda environments. Rather than changing an environment's Python, it is more straightforward to create the environment with the desired specifications at the outset. For example, something like
library(reticulate)
conda_create("myenv", python_version="3.11")

How can I know a anaconda installer is for which python version?

I want to install python3.7 by anaconda and the anaconda list is shown below:
anaconda version list。
My question is how can I know a anaconda installer is for a special verison of python?
Actually, I know "Anaconda3-2020.05-Linux-x86_64.sh" is for python3.7。However, I am confused that by what infomation we can get the answer before we finish installing it.
You can install specific version of python through the anaconda prompt, using:
conda install python = 2.7.8 or conda install python = 3.5.0 (for example).
You can even create a dedicated python environnement for a specific version:
conda create --name py36 python=3.6
Anton B answer is correct, but if you just want to download the correct installer, you can use the following:
For Anaconda you can use this: https://docs.anaconda.com/anaconda/packages/oldpkglists/
For miniconda you can use the tables on the following page: https://docs.conda.io/en/latest/miniconda.html
A similar question was previously asked here:
How to get anaconda/miniconda vs python versions mapping table?

conda env is forced to downgrade python version when using matplotlib

I created an environment in Anaconda Navigator and indicated python version as 3.6.4. After the env has completed, I installed matplotlib, numpy and so on, but when I was running Jupyter Notebook on a browser, it's shown the python version - Python 2, like the screenshot shown:
Then, I checked what I installed in this environment in Anaconda Navigator, it's really shown that python version is 2. So I was trying to upgrade python version to 3.6.4, then it's prompted that as shown below, complaining: functools32 and python 3.6.4 can not be satisfied and in conflict.
Then I searched google what is functools32, the result is a dependency of matplotlib
I'm looking forward to get an answer from you. Thanks In Advance.
Updated: April 1st
As the screenshot shown, it hinted to me that Python will downgrade from 3.x to 2.x when I was trying to install PIL.
If you think you created an environment with Python 3.6.4 but the environment actually has Python 2.x then either you made a mistake while creating the environment, or you aren't actually using the environment you created, or one of the packages you installed after creating the environment forced a downgrade from 3.6.4 to 2.x (and I'm not sure if that's even possible).
If you open an Anaconda prompt and type
conda create -n new-env-name python=3.6.4 matplotlib
(where new-env-name is the name you want for your environment) then conda will show you what packages and what versions it is going to install in order to satisfy the dependencies of matplotlib. When I try this it lists Python 3.6.4 (as I asked) and matplotlib 2.2.2, but doesn't mention functools32.
I would try creating your environment from the command prompt as above, and then make sure this environment is actually the active one before using it.

Confusion and conflicts with multiple Python bins and package locations

*I hope this isn't a repeat. I've tried looking for clarity, but I'm having trouble.
I'm fairly new to Python and used Homebrew to avoid using the system Python on Mac. I guess I also installed anaconda at some point. (probably following some tutorial)
Now when I do which for the following, I get different bins:
which python: /Users/ryangoree/anaconda3/bin/python
which python2: /usr/local/bin/python2
which python3: /Users/ryangoree/anaconda3/bin/python3
which pip: /Users/ryangoree/anaconda3/bin/pip
So my issue is that when I'm using python2, there are modules that that I can't use. If I try to pip install them, It just tells me they're already installed since they are in the anaconda directory.
I don't know what I don't know right now, but I'm sure there is a better way to handle this. Can someone enlighten me or send me on the right path to developing with Python and managing the packages.
Thank you!
This stumped me for a while until I figured out one pain when using anaconda: just because you’re in a conda environment doesn’t mean that pip belongs to that environment. Instead you must run conda install pip for pip to be associated with that environment. Then every pip install will be tied to that environment.
You can check your PYTHONPATH to see the order in which the various python installations are interrogated.
Better still you should create each conda environment with its own python using:
conda create -n <envname> python=2.7 # python 2.7
conda create -n <envname> python=3.6 # python 3.6
which will automatically include pip for that environment.

How to install Matplotlib for anaconda 1.9.1 and Python 3.3.4?

I am configuring Anaconda 1.9.1 together with Python 3.3.4 and I am unable to setup Matplotlib for anaconda environment when I try to add package using Pycharm. I also tried to install from Matplotlib.exe file which I downloaded from its website. I can not change the installation directory in that case. I would like to know that is there a way to tackle this issue.
If you're using anaconda, your default environment is Python 2.7. You need to create a new environment and install matplotlib in there.
In a command prompt, do the following (saying yes to the questions):
conda create --name mpl33 python=3.3 matplotlib ipython-notebook
activate mpl33
ipython notebook
You should be able to import matplotlib when the notebook server comes up.
The first command simultaneously creates the environment and install
the listed packages.
The second command activates the new environment by prepending its location to the system path
The third command just starts the ipython notebook so that you can test out everything
I don't know how pycharm works, but my guess is that you'll have to tell it to look for the right python that you want to use. In this case it'll be something like: C:/Users//anaconda/envs/mpl33. In any case, the command prompt should display the path when you activate the environment.
Once you've activated your environment, you can install more packages like this:
conda install pandas=0.12
conda install pyodbc statsmodels
You can specific version numbers of packages like the first command or simply accept the latest available version (default)
Assuming you've already installed a 3.x python env in anaconda, this one line should do the trick:
conda install matplotlib -n name
where name is the name you previously gave to your python 3 anaconda env. If you're not sure of the name you gave it, it will be the name of a subdir in the Anaconda\envs directory.
Background: I recently went through the same trouble with matplotlib not getting installed by default by anaconda when I added a full python 3 env, even though it's meant to. The above line solved it for me; it gave me the following warnings so it seems likely that the two different available versions caused it to initially install neither. However it allowed me to choose the one I wanted, and then everything worked great.
Warning: 2 possible package resolutions:
[u'dateutil-2.1-py33_2.tar.bz2', u'matplotlib-1.3.1-np18py33_1.tar.bz2', u'numpy-1.8.0-py33_0.tar.bz2', u'pyparsing-2.0.1-py33_0.tar.bz2', u'pyside-1.2.1-py33_0.tar.bz2', u'python-3.3.5-0.tar.bz2', u'pytz-2013b-py33_0.tar.bz2', u'six-1.6.1-py33_0.tar.bz2']
[u'dateutil-2.1-py33_2.tar.bz2', u'matplotlib-1.3.1-np17py33_1.tar.bz2', u'numpy-1.7.1-py33_3.tar.bz2', u'pyparsing-1.5.6-py33_0.tar.bz2', u'pyside-1.2.1-py33_0.tar.bz2', u'python-3.3.5-0.tar.bz2', u'pytz-2013b-py33_0.tar.bz2', u'six-1.6.1-py33_0.tar.bz2'
]
conda install -c conda-forge matplotlib

Categories