conda env is forced to downgrade python version when using matplotlib - python

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.

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")

Remove newer version of python using Homebrew, keeping an older version OR using site-packages in newer version

I have used python 3.8.13 as installed by Homebrew for years, mostly with jupyter-lab for coding in notebooks. Recently I ran brew to install a package and it looks like it installed python 3.10: brew list shows both python#3.8 and python#3.10 and running python3 from the command line gives me a 3.10 session, with no knowledge of my site-packages...
I either want to:
remove python 3.10 and continue using 3.8 as I was. python#3.8 would then be the python3 command as it was before.
or
change over to using python 3.10 and have all the site-packages installed when using 3.8 "come with". In particular, jupyter-lab needs to know about them in the 3.10 environment so my notebooks keep working.
Could someone help me with either of these? I'm not familiar enough with brew or python to clearly see how to do either to completion. Thanks so much.

Problem installing tensorflow in virtual environment

This issue in some form has come up before, however I am having a variant of this issue.
I had python 3.8 installed. Tensorflow does not have a version for this python.
I therefore installed python 3.7 and set up a virtual environment using virtualenv.
In visual studio code I even updated the settings json "python.pythonPath": to the correct path for version 3.7 of python.
I install the correct version of tensorflow using the correct link for 3.7 on the site:
'''pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl'''
But i still get the error
"ERROR: tensorflow_cpu-2.1.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform."
When i type python -V I still get Python 3.8.1, could this mean I am not correctly using the virtual environment?
However I have now set up virtual environment using anaconda which is limited to 3.7 and it still says 3.8 when using "python -V" and i get the same error when trying to install.
You can try to either reinstall anaconda, visual studio, or type in the command "pip install --upgrade tensorflow". This should work without the link.
After creating the virtual environment you need to activate it if you haven't already. Once you do, your command line prompt should indicate that a new version of Python, in your case 3.7 is now running.
I ended up using Anaconda with Python 3.6, it seems tensorflow would not work for 3.7 on windows.

How to change python version in Anaconda?

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.

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