I have miniconda installed in my mac system. Back when I was installing I had downloaded the python 3.6 mac OS 64-bit (bash installer) from https://docs.conda.io/en/latest/miniconda.html
currently, there is python 3.7 bash session is available, I tried to install the latest bash after downloading with the below command,
bash Miniconda3-latest-MacOSX-x86_64.sh
after the license process and directory set to my old one (in the home directory) I see the error
ERROR: File or directory already exists: '/Users/xxxxxxxxxx/miniconda3'
If you want to update an existing installation, use the -u option.
What am I missing here. My primary reason to update is to update the python version. Since with "conda update conda" I only get python update of the 3.6 series. I want to update to 3.7 series of python.
Thanks.
There is no need to update Miniconda to change the Python version.
If you want to use a different Python version for certain projects, create new conda environments. Each conda environment can use a different Python version, and it is completely independent of the Python version in the base environment.
conda create -n myenv python=3.7
If you want to change the Python version of the base environment, use
conda install -n base python=3.7
Related
I currently use this command to create a new anaconda environment:
conda create --name=<myEnvNameHere> python=3.9.5
I determined that 3.9.5 is the latest version of python available in anaconda with this command:
conda search -f python
How can I use just one command to create a new environment with the latest available version of python, perhaps something like:
conda create --name=<myEnvNameHere> python=latest
I know I can write a script to achieve the outcome I am after, but is there a way to do it in the conda create command natively?
According to the documentation for conda install, conda will (when no version is specified, it seems) try to install the latest version of the specified package(s).
Hence, you should be able to get the latest version of python in your new environment by running a command like this.
conda create --name=<myEnvNameHere> python
I currently have a python 3.7 installed by using anaconda on the machine. My intention is to create a lower version of python environment, say 3.6, for reason of compatibility. I follow the documentation to create the conda environment as conda create -n py36 python=3.6 However, this environment is a clean version of python, where many additional package like numpy, scipy are missing and these packages are already installed on python3.7. So what is the best way that I can create not only a python but also migrate all other packages in previous python version.(python3.7)
I understand the dependency may be different since some packages are not compatible with old version of python, but I still want to migrate as many packages as possible and let conda itself to decide the dependency tree. Current, what I can do is to first create a clean environment and manually conda install numpy and so on, which definitely not a good idea.
#Save all the info about previous env in requirements file
conda list -e > requirement.txt
then change the python version in the created 'requirement.txt' file
#the create new env from requirement file:
conda env create -f requirement.txt
My Ubuntu system is on python 2.7.15
conda install -c anaconda flask
Anaconda always installs python 3.5 with Flask and other packages. How can I not install python 3.7 and leave python 2.7.15 as is when installing anaconda packages?
The Python you install with anaconda does not interfere at all with your system Python. You can use Anaconda to have multiple Pythons (in multiple conda environments) besides the system Python. You just have to make sure which one is invoked when you run scripts and make sure it's the one you intended.
To answer the "literal" question you asked, you can specify the Python version when installing something:
conda install -c anaconda flask python=2
This will keep your Python at version 2 or report a mismatch if the package you want to install isn't available on anaconda for Python 2. The number of packages dropping Python 2 support is increasing because Python 2 is near it's "end of life", so don't expect to get latest or even near-latest releases of the packages when keeping at Python 2.
Personally I would recommend to create a different environment instead of trying to install to much into the base environment:
conda create -n mypython2environment python=2 flask
And by activating that environment you should be able to use the packages you installed in that environment:
activate mypython2environment
Several IDEs have built-in support for conda environments, so these may be helpful (especially in making sure you use the correct environment and thus the correct Python).
Before installing conda, my system has a python 2.7 installed; then I installed conda for python 2.7 with 64-bits from the official package for macOS.
Now it looks like my python binary has been 'moved' to a different place
ss-MacBook-Pro$ which python
/miniconda2/bin/python
Question 1: Has my old python binary been erased and a new version of Python get installed under /miniconda2/?
I then created a new environment with conda create --name testenv python=2.7, and the conda env list
ss-MacBook-Pro$ conda env list
# conda environments:
#
base * /miniconda2
testenv /miniconda2/envs/testenv
Question 2: Did I install a new python binary under /miniconda2/envs/testenv? i.e., is the python binary in each environment a separate binary package from base environment or other environments even thought they are the same version?
Installing Anaconda, installs another instance of Python. It won't affect your other installations, but it might change the default python for certain applications. This would append the Anaconda Python path to the PATH environment variable in ~/.bashrc (for Unix). This is one of the parameters that you can set during installation. Your system Python should still be there (probably at /usr/bin/python) and any other Python installations you may have had.
Creating another environment installs yet another installation. In fact, you have the option of creating an environment with Python 3. These are kept within the env directory within the main Anaconda directory. You can list them with conda env list.
As I understood, I have two versions of python 2.7 installed on my machine. One is located in /usr/bin and another one is in /usr/local/bin. When I type python in the shell, it calls one in /usr/local/bin, and it doesn't have access to all the packages installed using apt-get and pip. I have tried to set up an alias, but when I type sudo python it still calls one in /usr/local/bin. I want to always use one in /usr/bin, since I have all the packages there. How do I do that?
From what I understood,
You have two version of python. One is in /usr/local/bin/python
and another is in /usr/bin/python.
In your current configuration default python ->
/usr/local/bin/python
You want to use the one that is in /usr/bin.
Update your ~/.bashrc and append this line at the end
alias python=/usr/bin/python
Then open a new terminal. Or do source ~/.bashrc in the current terminal
Run which python to see the location of the python executable. It will show you /usr/bin/python
Also, if you want to get packages in your current python (i.e. /usr/local/bin/python) you can use pip with that particular python version.
Find pip location using which pip
Assuming pip location is /usr/local/bin/pip
/usr/local/bin/python /usr/local/bin/pip install
you can easily have two python version in your machine.
But first I recommend to install the Anaconda package.
And then you can create an environment with python 3 version
conda create --name test_env python=3 numpy pandas
In order to activate it, you need to write in your terminal
source activate test_env
More info here:
https://conda.io/docs/using/envs.html