How to update Python in Anaconda base environment? - python

How can I update Python in the Anaconda base environment? Is Python intended to be upgradable in the base environment at all, or should one completely remove and reinstall Anaconda? Any version will eventually go out of support, so there should be some solution.
What I have tried so far, and did not result in Python getting updated:
conda update --all
conda update python and conda update anaconda
conda install python=3.9 or conda install anaconda=2021.11 do not finish after an hour and a half.
mamba install python=3.9 results in "package python_abi-3.7-2_cp37m requires python 3.7.*, but none of the providers can be installed"
No other suggestion is put forward here.

I had a similar problem:
conda install anaconda=2022.10 resulted in unresolvable conflicts, conda install python=3.9 as well.
I finally managed to update by specifying both requirements within the same update command:
conda install anaconda=2022.10 python=3.9

In the base environment, run mamba update python --no-pin (of course, you could do it with conda, but then you're up for a long wait!).

Official documentation by Anaconda advises against upgrading to another major version of Python. It mentions the method you have already tried:
conda install python=3.9
but the process did not finish for you. This is in line with their documentation which says:
It is not recommended, rather it is preferable to create a new environment. The resolver has to work very hard to determine exactly which packages to upgrade.
Instead, you should create a new environment as suggested by the documentation and answers to this question.
conda create -n py39 python=3.9 anaconda

Open the Anaconda prompt by searching for it in the start menu or by running "anaconda-prompt" in the command prompt.
Run this command in the Anaconda prompt to update the base environment:
conda update --all

Related

Install GLIBCXX_3.4.29 in anaconda

I've seen Where can I find GLIBCXX_3.4.29? which doesn't answer my specific question.
I've got GLIBCXX_3.4.29 according to strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX. I'm specifically asking how I get it in my anaconda environment. I've got the most recent version of conda, 7.2.0 as per the install instructions conda libgcc but the GLIBCXX_3.4.29 doesn't meet the version required by some code I'm running
Addressing comment below
Would be better to know what you are trying to run
I'm trying to run some code that uses an in-house .so file. I've managed to run it before but I'm guessing that something changed when I updated a library used in generating the .so file.
Note: I've tried git checkout the library to an older version and rebuilding all of it but I'm still facing the issue.
How I created the env
conda create -n crannog python=3.6
conda activate crannog
pip install -r requirements.txt
Pastebin of Requirements.txt
Pastebin of conda list
Using answer from the comments, this worked perfectly:
conda install -c conda-forge gxx_linux-64==11.1.0
It installs the latest version of GlibC compatible with your Conda environment.
To install a specific version of GlibC (as pointed out by #Milad in the comments)
conda install -c conda-forge gxx_linux-64==XX.YY.Z
I tried to update the gxx_linux-64 as mentioned but it didn't find the package. Then I updated my conda by
conda update -n base -c defaults conda
and then deactivated my environment and activate the environment again. It worked. I am not sure which step worked.

How to install the specific version of Python with Anaconda?

I want to install Anaconda with Python Version 3.6.5. If I install Anaconda3-5.2.0, It install Python 3.5.1. Where to download the Anaconda with Python 3.6.5. The Big Data Scripts work only with Anaconda Python 3.6.5.
Anaconda Downloads
The Anaconda distribution with Python 3.6.5 was version 5.2.0.1 You can download this from the Anaconda distribution archive. If you do install from this, then make sure to update Conda immediately after installation:
conda update conda
However, I strongly recommend the following alternate solution as better practice.
Miniconda + Anaconda environment
Reasoning
What is installed in the base environment is relatively fixed once installed. Ultimately, you don't want to mess with your base environment, so best practice is to have the latest version there. Fortunately, you don't have to install a full Anaconda distribution, but rather can use a lightweight Miniconda (or Miniforge) distribution and create a secondary environment for the purpose of having an Anaconda Python 3.6.5 distribution. In the long run this will give you better stability.
Steps
Download and install Miniconda or a Miniforge variant. Once that is working...
Create your Anaconda env:
conda create --name my_env -c anaconda python=3.6.5 anaconda=5.2.0
Use your new isolated env:
conda activate my_env
[1] I determined this by running conda create -n foo --dry-run -c anaconda python=3.6.5 anaconda and then examining the version of the anaconda package that Conda ended up with in the solve.
Also try
conda install python=3.6.5
but you may encounter some incompatibility issues with other packages.
Alternatively, you may want to try creating a new environment. From the anaconda prompt, create a custom environment and specify the repository channel to find the version
conda create --name py365 python=3.6.5 --channel conda-forge
Activate the new environment
conda activate py365
However, the activation will not be permanent, and you will need to activate each time you start the anaconda prompt.
In your anaconda prompt, you can manually update your python to the latest version with :
conda update python
In case you are not familiar with it, anaconda prompt is installed to your computer when you install anaconda. Just make a search for it on your computer.
You can refer to this post : How do I upgrade to Python 3.6 with conda?

Is it safe to run conda updates that leads to custom package?

To be on the safe side, I was advised to keep to
$ conda update anaconda
However, some tutorials on internet recommends
$ conda update conda
$ conda update --all
The above two commands lead to the installation of custom packages. Will it cause anaconda to be unstable? Is it safer to simply keep to conda update anaconda?
Custom packages refer to packages with names that contain the word "custom". They do not belong to the standard anaconda package.
conda packages with version name of 'custom'
I am using Anaconda Python version 3.
Open "Command or Conda Prompt" and run:
conda update conda
conda update anaconda
It's a good idea to run both commands twice (one after the other) to be sure that all the basic files are updated.
This should put you back on the latest 'releases', which contains packages that are selected by the people at Continuum to work well together.
If you want the last version of each package run (this can lead to an unstable environment):
conda update --all
If you are implementing some projects and they depend on the previous version of some packages then running $ conda update --all will be disastrous. It may break some of the code from your project.
Running $ conda update anaconda will be a safe option because along with anaconda it will update all of the required dependencies to the required version.

Importing a package installed with anaconda in virtual environment

I want to work with the python package holopy. Apparently you have to use conda to install it, so I first installed Anaconda 4.2.0 (since I'm using Python 3.5). I opened the virtual environment I normally use and installed holopy as they recommend on the official site:
conda install -c conda-forge holopy
Afterwards, when in the virtual environment I type conda list, holopy shows up. But when I type python3 and then import holopy, it says package not found. It does however work when I leave the virtual environment. I need it in the virtual environment though, how can I do that?
I'm not sure how well anaconda and virtual environments i.e.venv work together. If you're using anaconda anyway then I highly recommend using anaconda environments. Please go through this short tutorial about anaconda environments - you won't regret it.
Why it didn't work for you?
The conda command is available only in the base anaconda environment. So when you run the command - conda insall -c conda-forge holopy, it installed holopy in the base anaconda environment and it won't be available to you in your venv.
After looking at the documentation of holopy it seems probable that when they said virtual environment they actually meant anaconda virtual environment. Therefore the solution is to first create an anaconda virtual environment called holopy-env and then run the command conda install -n holopy-env -c conda-forge holopy.
A better way of doing things with Anaconda
I will also give you a quick and clean example of how to create an environment using anaconda. If you're using Anaconda then it would be wise to use it's environment management tools. Create an environment.yml file with the following contents:
environment.yml using conda-forge/holopy & python 3.6
name: holopy-env # any name for the environment
channels:
- conda-forge
dependencies: # everything under this, installed by conda
- python=3.6
- holopy
- pip: # everything under this, installed by pip
- future
How to install the environment?
conda create --force -f environment.yml
How to activate the environment?
source activate opencv-env
After activating the environment
You should be able to import holopy
Install pip packages using pip install <package>
Install conda packages using conda install -n holopy-env -c CHANNEL <package>
conda is a packaging tool and installer that aims to do more than what pip can do; handle library dependencies outside of the Python packages as well as the Python packages themselves. Conda also creates a virtual environment, like virtualenv does. For creating virtualenv with conda, use the following command:-
conda create -n yourenvname python=x.x anaconda
Use the following to activate the virtualenv in conda
source activate yourenvname
Then, you can install the packages in virtualenv using conda as:-
conda install -n yourenvname [package]
To Deactivate use:-
source deactivate
And to delete a no longer needed virtualenv, use :-
conda remove -n yourenvname -all
I know this is a bit late, but you don't need to use conda to install HoloPy. This is just the least technical option. Otherwise, you need to be able to compile HoloPy's fortran components yourself, which is fairly straightforward on Unix-based systems but complicated on Windows. Instructions can be found in HoloPy's documentation at https://holopy.readthedocs.io/en/latest/users/dev_tutorial.html.
We are also working on putting together a singularity container distribution of HoloPy. Let me know if this is of interest to you and I will make it a priority.

Upgrading to python 3.6 with conda

I am trying to upgrade from python 3.4 to 3.6 and to reinstall all the packages from my 3.4 version into the 3.6 version automatically.
Now apparently it is not possible to upgrade in place for a major version, so i resorted to create a new conda env with conda create -name python36 python=3.6. i also tried to upgrade it place but it failed.
Before that I created a list of the module in my 34 version by type conda --list > packages.txt
I tried to install both pandas and the packages using conda create -name python36 python=3.6 --file packages.txt but i receive an error message could not parse 'anaconda-client 1.6.0 py34_0' in: python3_packages.txt. I tried to create the env, then to install the packages but same pb.
Any idea what is wrong here? I saw the other questions about that on SO but they dont touch of the topic of the installing of packages from text files.
It would be wise to update the anaconda itself. This would make updates on all the packages installed including python to 3.6. Use the code below on your anaconda terminal.
Make sure you run the terminal as an administrator
conda update python
There are a few ways you can replicate environments. You may want to try all of these options if one isn't working. You can export using one of these two commands. You must first have activated the environment that you are trying to export.
conda list > environment.txt
conda env export > environment.txt
You can create an env from a text file using:
conda env create -f environment.txt
conda create --name MyEnvironment --file environment.txt
I noticed that you typed "-name python36" which might be a typo but it must be "--name python36."

Categories