How to install the specific version of Python with Anaconda? - python

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?

Related

Switching between Python 3.7 and 3.8 under Anaconda

I have an Anaconda installation on Windows 10 primarily to run Jupyter Notebook and Spyder.
I find the Python runtime (python.exe) in 3 places after installation, viz:
D:\ProgramData\Anaconda3
D:\ProgramData\Anaconda3\pkgs\python-3.7.6-h60c2a47_2
D:\ProgramData\Anaconda3\pkgs\python-3.8.2-he1778fa_13
The python.exe under 1. and 2. are identical and run Python 3.7. 3. runs Python 3.8.
Questions:
What is the rationale of having two versions under pkgs (as in 2. and 3. above) but just one default version (as in 1.)?
The contents under the pkgs directory - are they complete Python installations?
What is the best way to make Jupyter Notebook pickup Python 3.8? It currently picks up Python 3.7 because the location 1. is in PATH. (That is, are the pkgs directories full installations)?
If I want to work with Python 3.9, is there a way to upgrade the current Ananconda to that extent? Or, do I have to delete the current Ananconda3 and install the latest Anaconda provided, of course it supports Python 3.9?
What is the rationale of having two versions under pkgs (as in II and III above) but just one default version (as in I)?
The contents under the pkgs directory - are they complete Python installations?
The pkgs folder is only a type of cache where packages that conda downloads and decompresses are kept so that they can be installed more quickly into new environments, so no they are not complete python installations ready to be used. There can only be one python version in one environment, in your case D:\ProgramData\Anaconda3\python.exe is the one that belongs to the base environment
If I want to work with Python 3.9, is there a way to upgrade the current Ananconda to that extent? Or, do I have to delete the current Ananconda3 and install the latest Anaconda provided, of course it supports Python 3.9?
To install a different python version into the current environment, simply do conda install python=<version>. You can use conda search python to check the available versions, or see on the website that the default channel has 3.9 as a newest version. However upgrading your base will most likely fail. Anaconda comes with a huge list of preinstalled packages and python 3.9 is too new, so that conda will not be able to resolve dependencies with newer python versions. The newest anaconda installer comes with python 3.8. only
What is the best way to make Jupyter Notebook pickup Python 3.8?
To have multiple python installations, use virtual environments (as there can only be one python version in one environment) which is very easy to use:
conda create -n py39 python=3.9
conda create -n py38 python=3.8
conda create -n py37 python=3.7
would create three environments that you can selectively activate with
conda activate py37 #or
conda activate py38 #or
conda activate py39
To use an environment, you need to activate it and then you can also install packages for that environment, e.g. to set up jupyter for one of them, simply do
conda activate py37
conda install ipykernel jupyter
python -m ipykernel install --user --name py37 --display-name "Python 3.7"
then you can start jupyter as you are used to and select Python 3.6 as the kernel.
Note that for each environment you will need to install all packages again, there is no cross-talk between them, so doing
conda activate py37
conda install numpy
will install numpy only to the py37 env, not to base, py38 or py39

Spyder IDE plugins installation (spyder-unittest)

I am trying to install a plugin for the Spyder ide called spyder-unittest (description here).
I am using:
MacOS X Version 10.14.6
Anaconda Navigator 1.9.7
Spyder 3.3.6
Python 3.7
After a first attempt using the command
conda install -c spyder-ide spyder-unittest
the plugin did not work (i.e. the additional command Run unit tests was not available under the Run menu).
I also tried, without success:
conda install -c conda-forge spyder-unittest
I then uninstalled and installed once again Anaconda navigator, and tried conda install -c spyder-ide spyder-unittest. This time, I got a very lengthy output, indicating conflicts (please see image):
Now, I do not know what to do. Could someone please offer any help?
I also tried to install after going, through the Terminal, to the directory where I thought the Spyder plugins were installed. Same output as above.
Thank you very much in advance.
Cheers,
Orlando
I managed to install spyder-unittest without any errors on my computer.
I suggest creating a new environment to avoid any conflicts with other packages when installing.
First create a new environment using:
conda create --name env python=3.7
After creating the environment, activate it using conda activate env
Then install spyder-unittest using conda install -c conda-forge spyder-unittest

Install packages with Conda for a second Python installation

I recently installed Anaconda in my Windows. I did that to use some packages from some specific channels required by an application that is using Python 3.5 as its scripting language.
I adjusted my PATH variable to use Conda, pointing to the Python environment of the particular program, but now I would like to use Conda as well for a different Python installation that I have on my Windows.
When installing Anaconda then it isn't asking for a Python version to be related to. So, how can I use Conda to install into the other Python installation. Both Python installations are 'physical' installations - not virtual in any way.
Uninstall the other python installation and create different conda environments, that is what conda is great at.
Using conda from your anaconda installation to manage packages from another, independent python installation is not possible and not very feasible.
Something like this could serve your needs:
Create one env for python 3.5 conda create -n py35 python=3.5
Create one env for some other python version you would like to use, e.g. 3.6: conda create -n py36 python=3.6
Use conda activate py35, conda deactivate, conda activate py36 to switch between your virtual environments.

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.

tensorflow - cannot install tensorflow from Anaconda

I am trying to access tensorflow from two ways, both of which are failing:
Installed Anaconda (Windows 32 bit Python 3.6). Then, created a conda environment with Python 3.6 (also tried with 3.5) and Tensorflow. Then, I opened Spyder desktop app. In this Spyder, the tensorflow is not working (e.g. 'import tensorflow as tf' is not working).
From Anaconda Navigator, created an environment (using the GUI), with Python 3.6. Then, I filtered the "Not installed" packages, and searched for "tensorflow". I couldn't find any relevant tensorflor package. All I could find is "r-tensorflow" which is not relevant for me.
The attached image describes the 2nd problem.
Can someone help?
Screenshot of the step 2 above
Open an anaconda prompt, and create an environment with tensorflow like this:
conda create -n tf tensorflow
activate tf
# Verify that it works
python -c "import tensorflow"
Then, you probably have to specify that environment from within Spyder. Open Preferences->Console->Advanced Settings and set the python path to <anaconda_install>/envs/tf/bin/python.
tensorflow can be installed simply by running following commands
On mac/Windows use following command:
conda install -c conda-forge tensorflow
This will install the latest Tensorflow on your system. if you wish to upgrade it to newer verion then you can use the following command
conda update -f -c conda-forge tensorflow
However if you have the virtual environment created from anaconda then before doing these steps you have to activate the environment first and then run the command. With this trensorflow will get installed on your specific command
Please refer the example below for more details:
Creating a environment for Tensorflow
conda create -n “myEnv” python=3.6 anaconda
This will create virtual environment along with anaconda packages. Once this is done, Activate the Environment by :
source activate myEnv #(for mac)
conda activate myEnv #(for windows)
you will see the following.
Once the Environment is active. you can now install the packages you need as follows:
I am showing you the packages which i work upon on virtual environment and this will take care of most of your dependencies
conda update conda
conda upgrade conda
conda upgrade anaconda
conda install pip
conda install -c conda-forge opencv
conda install -c conda-forge tensorflow
conda install -c conda-forge keras
Hope this will solve your problem.
Open Terminal, then enter:
conda update conda
After installing done, enter:
conda install tensorflow
It will take some time based on your internet speed.
After installing, open Anaconda -> Spyder/Jupyter
import tensorflow as ts
Let's break it down in a couple of steps:
If you don't have, download and install Anaconda.
Access Anaconda Command Prompt for the environment that you want to install TensorFlow. If you don't have an environment created, access the Anaconda Prompt.
Assuming that you don't have an environment created, choose the name of your TensorFlow environment, such as "tensor" and install TensorFlow as following
conda create -n tensor tensorflow
conda activate tensor
If you want to install the GPU TensorFlow (Linux or Windows), in the environment "tensor-gpu", use the following
conda create -n tensor-gpu tensorflow-gpu
conda activate tensor-gpu
TensorFlow is now installed. For more information access their documentation.
Try to install Spyder within the Anaconda environment in which you want to use tensorflow. This resolved the issue for me.
I had been stuck on the exact same problem for the past 4 days. I could see 'r - tensorflow' and a few other packages but not the 'tensorflow' package. Apparently, i was using the 32 - bit version of Anaconda. I searched it up and found out that Tensorflow is not supported on 32 - bit platforms. So i uninstalled the 32 - bit version and installed the 64 - bit version. I followed the same steps as before and i was able to find the 'tensorflow' package in the 'not installed' tab.
In my case I used pip instead of conda and it installed without any issue. In my opinion pip installation is much faster than conda installation.
Use
pip install tensorflow
and its done.

Categories