How can I use both Anaconda versions (2.7 & 3.5)?

前端 未结 3 1854
失恋的感觉
失恋的感觉 2021-01-31 11:56

I was using the Anaconda 3.5 distro in a Windows 10 machine. Due to dependencies in libraries that I want to work with, I had to have the 2.7 version i

相关标签:
3条回答
  • 2021-01-31 12:18

    You can make Python 3.5 environment with your Anaconda 2.7:

    conda create -n py35 python=3.5
    

    Now, activate it:

    activate py35
    

    Finally you can install the desired packages:

    conda install numpy
    

    or, the whole anaconda:

    conda install anaconda
    

    The advantage of this approach is that you can also create Python 3.4 or 3.6 environments. Furthermore, you can create environments with different combinations and versions of libraries.

    Actually, it makes sense to create a new environment for each larger project.

    0 讨论(0)
  • 2021-01-31 12:21

    The best way to use both Python 2.7x and Python 3.5x together is Jupyter Notebook.

    http://jupyter.org/

    You will be able to work on your browser with IPython Notebook style interface which is great for working with scripting languages.

    I found some of these videos on YouTube very informative:

    1) https://www.youtube.com/watch?v=HW29067qVWk

    2) https://www.youtube.com/watch?v=e9cSF3eVQv0

    Besides Python 2.7 and 3.5, there are a bunch of other languages that you will be able run with your Jupyter Notebook. The various Kernels are available in this link below:

    https://github.com/jupyter/jupyter/wiki/Jupyter-kernels

    After installation, as you start your Jupyter Notebook, your browser will open up a new page showing your Home Directory. Among the 4 tabs (Files|Running|Clusters|Conda):

    1) The Files tab shows all the files in your Home Directory.

    2) Running tab shows all the Notebooks that are running.

    3) Clusters tab is provided by IPython parallel.

    4) Conda tab is where you need to add the Python version 3.5 (and other languages if needed) to your Jupyter Notebook (If Python 2.7 is default).

    If you are interested to try C++ with your Jupyter Notebook, there are a couple of Kernels available.

    1) JupyRoot - https://github.com/root-mirror/root/tree/master/bindings/pyroot/JupyROOT

    2) Cling - https://github.com/root-mirror/cling

    0 讨论(0)
  • 2021-01-31 12:25

    I also despise the virtual environment switch that Anaconda tries to force on us. I prefer to have both executables always instantly available from the command line. I'm pretty sure I had this working on a Windows machine once:

    1. Install Anaconda2 and Anaconda3 to the C:\ drive as "C:\Anaconda2\" and "C:\Anaconda3\" respectively.
    2. Edit your "Path" environment variable (Control Panel -> System and Security -> System -> Advanced system settings -> Environment Variables) and make sure that "C:\Anaconda2;C:\Anaconda2\Scripts;C:\Anaconda2\Library\bin" is in front of "C:\Anaconda3;C:\Anaconda3\Scripts;C:\Anaconda3\Library\bin".
    3. Copy and rename the file "C:\Anaconda3\python.exe" to "C:\Anaconda3\python3.exe".
    4. Copy and rename the file "C:\Anaconda3\Scripts\conda.exe" to "C:\Anaconda3\Scripts\conda3.exe"
    5. Copy and rename any other scripts you might use in "C:\Anaconda3\Scripts\", such as "pip.exe" to "pip3.exe", etc.

    Now, when you type "python" or "conda" at the command line you will get the python2 version, and when you type "python3" or "conda3", etc. at the command line you will get the python3 version.

    0 讨论(0)
提交回复
热议问题