How to run Anaconda side by side with other Pythons
The Anaconda distribution of Python packs a terrific numerous libraries and tools for info science and scientific computing beneath a one roof. Its attraction goes over and above scientific number crunching, nevertheless. Anaconda is also handy as a general intent Python distribution.
But Anaconda arrives with its share of snares and subtleties. What if you’re utilizing Anaconda together with other Python distributions, and you don’t want them stepping on just about every other’s toes? How do you combine Anaconda proficiently with your other Python tooling, like IDEs? And if you make your mind up you just want to use standard Python, how do you take out Anaconda without breaking anything at all else?
In this posting, we’ll appear at how to established up and operate with Anaconda together with standard variations of Python on the identical program. This posting assumes you previously have some variation of Python installed and you have a standard performing awareness of Python right before getting commenced. Notice also that most of the assistance here pertains to running Anaconda on Microsoft Windows.
Setting up Anaconda with other Pythons
When you run the Anaconda installer, you will not be greeted with a terrific numerous selections. But the few selections you are presented with make all the distinction when getting Anaconda to coexist with other Python installations.
The initial selection really worth modifying is in the “Select Installation Type” menu, where by you select between setting up Anaconda for Just Me or All Customers. If you’re on a pc where by you have admin privileges, selecting All Customers makes everyday living a terrific deal a lot easier, so find that selection if you can. If you select Just Me, the default choice is a subdirectory in your consumer profile, which may be a little tougher to uncover by default, but is nonetheless available as long as you know the route.
On the following menu site, you’ll be presented the probability to modify the directory where by Anaconda is installed. To make Anaconda simply available, place it in a directory (where by you have generate permissions) that is as higher up on the drive as attainable. For instance, on my program, I have the D:
drive reserved for applications, so I use D:Anaconda3
as my Anaconda install directory. You may not be capable to use a directory off the root of a drive if you’re setting up as Just Me, but the less difficult the route to Anaconda, the much better.
Here’s the big rationale you’ll want an simply available route: When you established up Anaconda to co-exist unobtrusively with other Python installations, you may will need to manually specify the route to the Anaconda interpreter, for the reason that it may possibly not always be car-detected, and for the reason that (by style and design) it will not be in your system Path
. The a lot easier it is to uncover, the much less headache later on.
On the following set up display screen, you’ll be presented with two selections: “Add Anaconda3 to the system Path
environment variable,” and “Register Anaconda3 as the program Python 3.seven.” Uncheck both options. The initial helps prevent current Python installations from having their Path
references short-circuited by Anaconda. The next keeps your current Python set up registered as the default interpreter in the Windows Registry.
Complete the relaxation of the install commonly.
Working with Anaconda virtual environments in a command line
The moment you’ve finished Anaconda set up, you’ll will need to configure command-line access to your Anaconda environments. This can be tough for the reason that of the way Anaconda’s surroundings program is effective: For Anaconda to operate properly, it has to activate at least 1 surroundings, this kind of as the foundation
environment. Just launching Anaconda’s python
executable doesn’t do this.
Anaconda provides some shortcuts to launching shell classes with the foundation
environment activated. For instance, in Windows, an Anaconda PowerShell Prompt shortcut seems in the Start off menu soon after you install Anaconda. Click this shortcut, and you’ll start a PowerShell session with the foundation
environment activated.
What if you don’t want to use the shortcut, but just want to trigger activation in any PowerShell instance you transpire to be in? This is trickier, for the reason that you have to execute the identical activation regime utilised in the shortcut.
You can do this by way of a .ps1
script with the subsequent line (assuming Anaconda is in D:Anaconda3
):
& 'D:Anaconda3shellcondabinconda-hook.ps1' conda activate 'D:Anaconda3'
Put that script somewhere in your Path
, and you’ll be capable to activate Anaconda manually from any PowerShell session.
Working with Anaconda virtual environments in growth tools
Most IDEs with Python assist now are sensible adequate to recognize the existence of an Anaconda set up and any virtual environments installed. For instance, Visual Studio Code’s Python plug-in will do this, even if the system Path
isn’t configured to place to Anaconda.
Now the undesirable news. Some IDEs, like Visual Studio Code, don’t combine elegantly with Anaconda’s surroundings activation program. As a outcome, if you have PowerShell chosen as the integrated terminal shell host, the IDE simply cannot activate an Anaconda surroundings when you open up the integrated terminal.
Luckily, there is a workaround for VS Code. Edit the .vscode/configurations.json
file for your challenge, and increase the subsequent location:
"terminal.integrated.shellArgs.windows": "-ExecutionPolicy ByPass -NoExit -Command "& 'D:Anaconda3shellcondabinconda-hook.ps1' conda activate 'D:Anaconda3' ""
Notice that if your route to Anaconda is unique, you’ll will need to modify the line over accordingly don’t forget to escape backslashes for Windows paths as in the over.
Now, when you kick open up the integrated terminal, the initial instructions passed to it will be the activation script for the Anaconda surroundings. You can modify this further more to activate a challenge-particular virtual surroundings if needed.
Getting rid of Anaconda
If you haven’t established Anaconda as your default Python set up, then uninstalling Anaconda utilizing its built-in uninstaller shouldn’t cause any issues. Other Python installations need to keep on being untouched and need to nonetheless operate.
If you authorized Anaconda to modify your Path
, go by both your consumer profile Path
and your system Path
and take out any Anaconda-connected entries.
Ultimately, it’s always very best to take out Anaconda soon after executing a complete reboot, or at least a logout/login, to be certain that no instances of Anaconda are running. Also make guaranteed you don’t have anything at all car-introduced in your consumer profile, like a background process, that operates Anaconda. Normally the elimination process may balk.
How to do much more with Python
Copyright © 2020 IDG Communications, Inc.