Is it possible to lock versions of packages in Anaconda? - python

I installed Anaconda 3 2.3.0 on Windows xp. It is supposed to be the last version of anaconda to support windows xp as it contains python 3.4.3, and python 3.4.x is the last version of python to support windows xp.
When installing a package with
conda install
,one of its dependencies was updating conda to conda 4.x. conda 4.x crashed in the commandline when running conda install . This made anaconda unusable that i uninstalled anaconda.
My question, is it possible to lock versions of packages ? For the two use cases:
lock and forget : for packages I never want them to update, i need to run a command to lock them once so they will never update as a depency
ignore updating : install a package while ignoring to update certain package passed by name in this update.
If only one of the 2 use cases is possible or is known or is easier, please write it as answer.

There are two bits to this. First, you can prevent conda from auto-updating by changing the configuration option auto_update_conda to False:
conda config --set auto_update_conda False
The other bit is to pin packages to certain versions. For those packages you don't want to update, you can pin the version by adding a line to a file called pinned (you might need to create it) in the environment's conda-meta directory. The syntax is
[The code] below [placed in conda-meta/pinned] forces NumPy to stay on the 1.7 series, which is any version that starts with 1.7, and forces SciPy to stay at exactly version 0.14.2:
numpy 1.7.*
scipy ==0.14.2
See the documentation for more information.

Pin for conda install (=): package=1.0
vs.
Pin for pip install (==): package==1.0

Try
pip install <package name==version no*>
for instance
pip install musdb==0.2.*
That would pin your package

Related

Installing a package from git in Anaconda environment which is afterwards not recognized in Python

I'm trying to install a python package directly from github. In my case that's SciANN. When I selected my environment in conda using conda activate myenv and afterwards install this package as explained in this post using the following lines of code:
conda install git pip
pip install git+git://github.com/sciann/sciann.git
it is successfully installed and I get the message "Successfully built SciANN" in the end of the insatllation procedure. When I then open spyder and type import sciann I get the error ModuleNotFoundError: No module named 'sciann'. I also tried to use pip3 instead of pip but this did not change something.
Have I missed something? Is this package now installed correctly into my environment myenv?
The deleted answer from Jay Prakash together with the comments brought me on track. Yes there can be different versions of packages installed. So in my case SciANN was installed using pip as they currently do not offer a conda installation while all my other packages where installed with conda. I ended up having two different versions of tensorflow installed, one from pip and one from conda so I deleted one. Additionally I used Python version 3.7 while this package supports only up to 3.6. And I had to use a non official tensorflow version because my CPU does not support AVX which is a whole new topic.

Can't upgrade Anaconda base to Python 3.8

I want to upgrade my base environment to Python 3.8. According to the official documentation, I should just run conda install -c anaconda python. This, however, only upgrades Python 3.7, so, in the end:
(base) C:\Users\bob>conda install -c anaconda python
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(base) C:\Users\bob>python --version
Python 3.7.6
conda update -c anaconda python only updated a number of packages, but not Python itself.
And if I specify a version, like explained here, after two hours analyzing dependencies, the upgrade fails because of conflicts.
I managed to set up a 3.8 environment, but I'd rather upgrade my base environment as it's the one my system path for use outside of Anaconda.
Any suggestion?
It doesn't appear to be possible to update the base version of anaconda to 3.8 yet because of the conflicts you mention. I assume once all the standard packages are updated to support 3.8+ (and updated versions of all dependencies), then the anaconda release will include 3.8.x as the default. This might take a while.
The problem here is version conflicts in the packages that anaconda installs by default. The reason you can install 3.8 in a clean environment is because no other packages are installed in that environment, so no conflicts.
This does now present a solution, although it requires reinstalling everything from scratch...
disclaimer: I don't use windows, so adapt my instructions accordingly to your OS.
Remove your existing anaconda install from the path and delete
anything in your bashrc (or windows equivalent) that points to it.
You can just delete/uninstall anaconda, but it's good to have a backup just incase, so leaving it there and removing links to it is a good option.
Download and install miniconda, and put it in your path as you had before.
Install python 3.8 in the base environment conda install python=3.8
Install all the packages that you need to do whatever you do.
Depending on what you install, at some point you may run into the same conflicts that prevent a standard anaconda install from updating at the moment, but that hasn't happened for me.
The latest stable version of anaconda is version 3.7
Please see here:
https://www.anaconda.com/distribution/
There isn't an option to get python 3.8, this is due to anaconda sometimes running a version behind the release of python.
I had the same issue and found there is a 2020-07 release of Anaconda with Python 3.8 https://www.anaconda.com/products/individual

python not using latest numpy version

I have a problem.
I need numpy 1.14.2, and my machine (Linux Mint 17.3) has only 1.8.2 installed.
I then installed 1.14.2 through pip. But when I load it in ipython, it still says that it is 1.8.2.
Using yolk I saw that 1.14.2 is actually installed, but marked as non-active.
numpy - 1.14.2 - non-active development
(/usr/local/lib/python2.7/dist-packages)
While for 1.8.2 it says "active".
Also, 1.8.2 is located in "/usr/lib/python2.7/dist-packages/numpy".
Why is there a difference? I dont see a reason why there are two libraries.
I read that python loads the libraries by the order in $PATH.
And indeed, when I look at sys.path, I see that /usr/lib... is listet before /usr/local ....
How can I change that? I dont have anything in .bashrc, /etc/profile or /etc/rc.local which would set this specific order.
Thx.
You should use a virtual environment. Your system most likely will default to the most up to date version.
Try installing:
pip install virtualenv
then run:
virtualenv -p python2.7 environment_name.
Source the virtualenv with:
source environment_name/bin/activate
then pip install numpy=1.14.2.
Then you will have a mini environment with the exact version you want and wont update. This way you can have multiple versions all contained in the same system.

How to upgrade to the latest Anaconda 5.0.1

I have Anaconda 4.4.0 (Windows, Python 3.6., 64 bit).
I would like to upgrade to latest Anaconda 5.0.1
Few options:
Download the full installer and run it
From existing installation (of 4.4.0) run "conda update --all"
From existing installation run "conda update anaconda"
What is the tradeoff among these options? What is the recommended one?
Download the full installer: Provided that you uninstall your existing Anaconda, this method will be least likely to cause upgrade problems. It will also probably be slower. Note that I think you should uninstall the old Anaconda so that you don't end up with two conda[.exe] files, two Anaconda Prompt shortcuts, and so forth. You may end up trying to install a package with the wrong conda and be very confused about what's happening.
conda update --all: This will update all of your packages in the environment to their latest version, regardless of their version in the Anaconda installer. This is not recommended because you will end up with package versions that are different from the ones in the Anaconda installer and you may end up with an error message about packages that are incompatible.
conda update anaconda: This will update the "metapackage" called anaconda to the latest version. This package has dependencies on specific versions of all of the packages and Anaconda (the company) give some assurance that these will all work together. So, updating the anaconda package will update all your packages to the version used in the latest version of the Anaconda installer.
My suggestion (based on some experience, I am not an employee of Anaconda) would be to try #3 and if it fails, try #1.

Which is the correct command to update all anaconda python packages?

I am using python Anaconda. I am confused which is the correct command to update all the Anaconda packages to the latest version. There seems to be 2 commands that can be used;
$ conda update --all
or
$ conda update anaconda
After running the latter, anaconda was upgraded to ver4.4. Subsequently, I run the former which asked if I wanted to downgrade some packages. This is what confused me. Which is the correct command to use?
The anaconda package is a "meta"-package, which means that it doesn't contain any packages itself, it merely sets the specific version of a number of packages that Anaconda Inc. (formerly Continuum IO) include with the "Anaconda distribution". Therefore, when you type
conda update anaconda
you are telling conda to update to the most recent version of the anaconda package, and install all the dependencies with their specific versions as specified in the anaconda package. This has the advantage that Anaconda Inc. (formerly Continuum IO) have tested the packages together and are making some assurance that there won't be any conflicts.
When you type
conda update --all
conda uses its internal algorithm to try and resolve the versions of the dependencies. I'm not sure of the details, but this may result in some packages being upgraded, but others being downgraded because some package that you have installed requires a downgraded version of the dependency. Particularly with the number of packages installed by the anaconda meta-package, conflicts are sure to happen, and conda is doing its best to resolve all those.
As for which to use, I'd say that if you started with anaconda, keep going with anaconda to avoid version conflicts (i.e., conda update anaconda). However, if you have a fresh environment or you're using Miniconda where you don't have the anaconda meta-package installed, then conda update --all is probably the better choice. Your mileage may vary.

Categories

Resources