I created a new python3 environment to install python 3; due to the incompatibility between conda and Windows PowerShell, I installed python 3 in both of the root and python3 environment by accident. Is it possible to revert to python 2 in the root environment?
C:\Users\Nick>conda info --env
# conda environments:
#
python3 C:\application\anaconda\envs\python3
root * C:\application\anaconda
C:\Users\Nick>python -V
Python 3.3.5 :: Continuum Analytics, Inc.
conda install python=2 should do the trick. Definitely check and make sure that all packages downgraded successfully by inspecting the output of conda list for versions that contain the py3 string. For any packages that contain py3 in the version string, you should probably just uninstall/reinstall them.
(Hypothetical) Example:
The third column in conda list is the python version. If you see:
anaconda-client 1.1.2 py35_0 defaults
then you should
conda remove anaconda-client
followed by
conda install anaconda-client so that it installs the python 2 version.
Then conda list should show the anaconda-client line like this:
anaconda-client 1.1.2 py27_0 defaults.
Related
While trying to install a particular package using conda, I didn't notice how many packages were going to be downgraded and foolishly gave the go-ahead. For the most part, the version numbers weren't downgraded, but they downgraded from a py37 build channel to a py27 build channel. Running conda list now gives me lines with a mix of py27 and py37:
jupyter 1.0.0 py37_7
jupyter_client 5.2.4 py27_0
jupyter_console 5.2.0 py27_1
jupyter_core 4.4.0 py27_0
jupyterlab 0.35.3 py37_0
I can't remember what it looked like before, but I don't believe I had this garbled mess of python2 and python3, as I haven't built anything with python2 into my conda. Running conda update --all doesn't resolve this, as I believe it only checks the version and not the build path. How can I change everything back to python3 and ideally remove all traces of python2?
Edit:
The line in particular that caused this was conda install -c menpo vtk=7 when trying to install DAETools
I think the easiest way to fix this should be to explicitly install python=3, i.e.:
conda install python=3
possibly this will want to remove vtk again, but when I specified python=3, I got a version of vtk=7 build with python 3.5 from the same channel you used, i.e. there is a python 3 version available.
It's also possible to revert your anaconda distribution back to 'factory settings' by executing conda update conda, followed by conda install anaconda. Afterwards all your package versions should be the same as the ones that you would have after a fresh installation of the (latest) full Anaconda distribution.
Background
I had Anaconda 5.2 with python version 3.6.5 On windows 10.
As the time of the writing, the latest Anaconda version is 5.3, which uses python 3.7.0. The latest python release is 3.7.1.
I used the following commands in cmd 2 times to update to the latest Anaconda:
conda update conda
conda update anaconda
The end result of above is that, the Anaconda is now version 5.3, but python is updated to the latest 3.6, but not to 3.7
list anaconda
# packages in environment at C:\Anaconda3:
#
# Name Version Build Channel
anaconda 5.3.0 py36_0
anaconda-client 1.7.2 py36_0
anaconda-navigator 1.7.0 py36_0
anaconda-project 0.8.2 py36_0
python --version
Python 3.6.6 :: Anaconda, Inc.
Question
how to update to the latest Anaconda with the latest python version it supports?
(Besides Uninstall&Reinstall)
Try
conda install python==3.7.0
then just create new environment with python version you want, like
conda create --name python3_7 python=3.7.0 --channel conda-forge
EDIT: just tested on my mac terminal and
conda update python
updated my python version 3.6.5 to 3.7.0
Anaconda is already the latest version but if you want to create python 3.7 environments you need to update python. Afterwards fire up Anaconda-Navigator and create a new environment and you will see "3.7" as one of your choices in the drop down menu.
To update anaconda to be the same as the latest official fresh installation (anaconda 5.3):
conda install anaconda=5.3
Why I cannot update conda from a conda environment, but I can use it?
An example
I can update conda from root
[ravas#localhost ~]$ source activate
(base) [ravas#localhost ~]$ conda update conda
Solving environment: done
# All requested packages already installed.
I cannot update it from p36:
(base) [ravas#localhost ~]$ source activate p36
(p36) [ravas#localhost ~]$ conda update conda
PackageNotInstalledError: Package is not installed in prefix.
prefix: /home/ravas/miniconda3/envs/p36
package name: conda
This seems to occurs as conda is not installed in p36
(base) [ravas#localhost ~]$ conda list | grep conda
# packages in environment at /home/ravas/miniconda3:
anaconda-client 1.7.1 py37_0
anaconda-navigator 1.9.2 py37_0
conda 4.5.11 py37_0
conda-env 2.6.0 1
(p36) [ravas#localhost ~]$ conda list | grep conda
# packages in environment at /home/ravas/miniconda3/envs/p36:
anaconda 5.3.0 py36_0
anaconda-client 1.7.2 py36_0
anaconda-project 0.8.2 py36_0
pdfminer.six 20170720 py36_0 conda-forg
However, from p36 I can use conda
(p36) [ravas#localhost ~]$ conda update anaconda
Solving environment: done
# All requested packages already installed.
Why is that?
This is a consequence of how the shell (Bash, zsh, csh, fish, etc.) finds programs to execute. (The shell is the program that is running to process the commands you type in the terminal). The shell looks for executables in folders that are specified in the PATH environment variable. It searches these folders in the order that they're specified in that variable. If you look at the contents of the PATH with your environment activated, it should look something like
$ echo $PATH
/home/ravas/miniconda3/envs/p36/bin:/home/ravas/miniconda3/bin:...
When the shell tries to find the conda executable, it looks first in the environment directory; when it doesn't find it there, it looks in the base directory, where it does find it!
conda is not installed in the new environment. But you can get a conda in that derived environment like this:
activate the base environment
activate your other environment
run a conda install conda
Now you have a conda in that other environment, and work with that environment as usually.
I have installed Anaconda on a Windows 10 machine which comes with Spyder and Python 3.6 but I wish to upgrade to Python 3.7
To create an Anaconda Environment with Python 3.7 is easy by using:
conda create --name py37 python=3.7
or:
conda create --name py370 python=3.7.0 --channel conda-forge
However starting Spyder in this environment will throw it back to Python 3.6.
I tried specifing the python.exe (for version 3.7) directly in Tools -> Settings of Spyder, however upon restarting the Spyder Kernels can't be launched and will display that they need the packages: ipykernel and cloudpickle .
When trying to conda install them in the environment the following appears:
The following packages will be DOWNGRADED:
python: 3.7.0-hea74fb7_0 --> 3.6.6-hea74fb7_0
Which would downgreade python from 3.7 to 3.6 again.
My final try was to use the command:
conda install python==3.7
which has failed with the output
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- python-dateutil -> python[version='>=2.7,<2.8.0a0']
- python-dateutil -> six
- python==3.7
Use "conda info <package>" to see the dependencies for each package.
The question is not how to upgrade Conda to Python 3.7, but how can I get Spyder to work with Python 3.7 in its own environment
When you run spyder from the CMD/terminal, your operating system tries to find the spyder executable on your system's PATH. In this case, it will default back to the base environment's version of spyder, which runs Python 3.6.
The best way I have found so far is to install spyder to the new environment; activate the environment, and then run spyder (which should fire up the version in the local environment).
conda create --name py37 python=3.7
conda install --name py37 spyder -c conda-forge
conda activate py37
spyder
However, this requires the version of spyder to support python 3.7. Currently that is not available (as of 2 July 2018), but it should not be too long coming.
EDIT:
Spyder for Python 3.7 is available.
I used pip to install the Resource module to the default conda environment on my laptop: (C:\Users\my_username\Anaconda2). I think it is called root. I installed pip to the conda environment and so I'm 90% sure the resource was installed within the environment. And indeed running conda list shows that the package is listed within the environment. Here is a section of the output:
# packages in environment at C:\Users\conna\Anaconda2:
#
qtpy 1.2.1 py27_0
requests 2.14.2 py27_0
Resource 0.2.0 <pip>
rope 0.9.4 py27_1
ruamel_yaml 0.11.14 py27_1
scandir 1.5 py27_0
scikit-image 0.13.0 np112py27_0
However when I run
conda update Resource
I get the following error:
PackageNotInstalledError: Package is not installed in prefix.
prefix: C:\Users\conna\Anaconda2
package name: Resource
How is it possible that conda list shows the module is present but conda update can't see them? I also noticed that conda update doesn't recognize any packages with <pip>. What is happening?
conda only manages the packages that are installed using a conda command. If you installed a package with pip (or using python setup.py install or develop) it will show up with conda list (because that shows all packages no matter how they were installed) but conda won't manage that package. Simply because it doesn't know how!
So if you installed a package with pip you also need to upgrade/update it with pip:
pip install [package_name] --upgrade
Try this;
pip install Resource --upgrade