I'm relatively new in macOS. I've just installed XCode (for c++ compiler) and Anaconda with the latest Python 3 (for myself). Now I'm wondering how to install properly second Anaconda (for work) with Python 2?
I need both versions to work with iPython and Spyder IDE. Ideal way is to have totally separate Python environments. For example, I wish I could write like conda install scikit-learn for Python 3 environment and something like conda2 install scikit-learn for Python 2.
There is no need to install Anaconda again. Conda, the package manager for Anaconda, fully supports separated environments. The easiest way to create an environment for Python 2.7 is to do
conda create -n python2 python=2.7 anaconda
This will create an environment named python2 that contains the Python 2.7 version of Anaconda. You can activate this environment with
source activate python2
This will put that environment (typically ~/anaconda/envs/python2) in front in your PATH, so that when you type python at the terminal it will load the Python from that environment.
If you don't want all of Anaconda, you can replace anaconda in the command above with whatever packages you want. You can use conda to install packages in that environment later, either by using the -n python2 flag to conda, or by activating the environment.
Edit!: Please be sure that you should have both Python installed on your computer.
Maybe my answer is late for you but I can help someone who has the same problem!
You don't have to download both Anaconda.
If you are using Spyder and Jupyter in Anaconda environmen and,
If you have already Anaconda 2 type in Terminal:
python3 -m pip install ipykernel
python3 -m ipykernel install --user
If you have already Anaconda 3 then type in terminal:
python2 -m pip install ipykernel
python2 -m ipykernel install --user
Then before use Spyder you can choose Python environment like below!
Sometimes only you can see root and your new Python environment, so root is your first anaconda environment!
Also this is Jupyter. You can choose python version like this!
I hope it will help.
This may be helpful if you have more than one python versions installed and dont know how to tell your ide's to use a specific version.
Install anaconda. Latest version can be found here
Open the navigator by typing anaconda-navigator in terminal
Open environments. Click on create and then choose your python version in that.
Now new environment will be created for your python version and you can install the IDE's(which are listed there) just by clicking install in that.
Launch the IDE in your environment so that that IDE will use the specified version for that environment.
Hope it helps!!
Related
Yesterday I uninstalled my Python 3.6 and installed Python 3.7. I simply ran the executable and followed the prompts. Here is a screen shot of my Programs and Features in my Control Panel.
However, when I check the version in the command prompt, it seems like version 3.6 is still running!
If you have an Anaconda Python installation, you can either upgrade it to your chosen version of Python or create a new conda environment with the version you want.
To see what environments you have set up, do conda env list
To upgrade Python in an environment myenv, do activate myenv then conda update python (to get the latest version) or conda install python=x.y.z (to install version x.y.z, assuming it's available from your conda channels)
You probably didn't completely uninstall your old python version and windows is still pointing to the old installation. Edit your PATH and point your new python 3.7 directory.
Go to My Computer/This PC --> right click --> properties --> advanced system settings --> environment variables --> PATH
You should see a path directory that looks something like this:
C:\Users\Programs\Python\Python36\
Change that directory and point to your python 3.7 installation.
If you want you can keep the old installation of python 3.6 on your computer, it's not necessary to uninstall it and you can work on projects using older python versions when needed.
It looks like you have a Python executable in your PATH from a Anaconda installation (hence the Anaconda Inc at the end of your version number).
You have a few options here:
You can either find the Anaconda installation and remove it (echo %path% into the command prompt may help).
Edit your PATH to make sure that your Python 3.7.3 installation is called first before the Anaconda install.
Upgrade your Anaconda installation to the latest version that uses Python 3.7.
When you install anaconda, a box is automatically checked to make your computer see the version of python installed with conda as the primary version, you could probably uninstall conda or change you system env path taking conda off it.
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).
It makes me crazy, In anaconda I create the environment with the defualt iterpreter python3.4 Next I install pytorch 0.4.1
conda install pytorch=0.4.1 cuda80 -c pytorch
After this I found that the pytorch was installed in python3.6!
And the environment defualt interpreter is chaged from python3.4 to python3.6.
I am very confused what happend ? How shoud I fix it back? change defualt python back to python3.4? Hope some one could help me.
The commands I typed in are as follows:
conda create -n pointgen python=3.4 ipykernel
source activate pointgen
conda install pytorch=0.4.1 cuda80 -c pytorch
Thats all. What Novak said is right, there is remaining question is how could I manually change the python version from 3.6 back to 3.4, is there any config file I can deal with?
As you can see here there is no version of pytorch for python3.4... The default version of pytorch is for python3.6 and that is the version you installed installed. In the process anaconda prompts you that it will have to upgrade/downgrade some package versions and there is probably the the line in which it says it will upgrade python to 3.6
After activating my anaconda Python 3.6 environment with
source activate py36
if I type
python
I go into python 3.6, as expected. But if I type
ipython
I go into an ipython environment based python 3.5.5, which is the same python version I get using
source activate base
and then
python
How can I get into an ipython environment using my anaconda-supplied python 3.6 interpreter? I have updated my anaconda environment with
conda update anaconda
and
conda update conda
Doing so does not help.
EDIT:
I hadn't realized that I had to install ipython separately for the python 3.6 environment; I'd thought it was a default part of anaconda. So
conda install ipython
after
source activate py36
did the trick. It doesn't seem optimal that after activating a particular environment, ipython may bring up a completely different anaconda-based environment. I'd prefer it to simply cause a "command not found" error. Bringing up the wrong environment without making it very obvious that that is happening could lead to confusion or problems.
I hadn't realized that I had to install ipython separately for the python 3.6 environment; I'd thought it was a default part of anaconda. So
conda install ipython
after
source activate py36
did the trick.
Have you done hash -r since entering the conda environment? Bash can cache paths to executables, so sometimes it doesn't use the one reported by which. Running hash -r resets the cache
Maybe you need also to update ipython conda update ipython
I have been trying to install GraphLab Create on my system (64bit, Windows 10).
I used the Installation guide as given on the site https://turi.com/download/install-graphlab-create-command-line.html
I used the command line since I already had Anaconda3 installed in my system.
I tried the Method - 1 but it didn't work because I'm not using Python2.7, but Python3.5.2, so, I tried Method - 2 by using Virtual Environment.
I am getting a Syntax error when I try the command:
virtualenv gl-env
I have already installed Virtual Environment through pip so this should not happen, right ?
Please help me out on what could possibly be wrong.
From the installation instructions page:
GraphLab Create installation requires a Python 2.7.x environment and pip version >= 7
You have to install GraphLab in a Python 2.7 environment, and not in a Python 3 one.
Thus, install python2 first and then follow the rest of the instructions:
conda create -n gl-env python=2.7 anaconda=4.0.0