Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anaconda activate

Tags:

linux

anaconda

I am using anaconda python. So every time, in my mac terminal, I input the terminal command:

source /Users/mylaptop/anaconda/bin/activate /Users/mylaptop/anaconda

And then I activated the anaconda python environment. But I don't want to write this command line every time, so I tried a bash script like this:

#! /bin/bash

source /Users/mylaptop/anaconda/bin/activate /Users/mylaptop/anaconda

and I put this file in the directory /usr/local/bin. But unfortunately, I cannot log into anaconda environment in this way. There is no error message showed up in the terminal. So I do not know what is happening here.

Could anyone help me out?

like image 834
spind Avatar asked Dec 01 '14 00:12

spind


People also ask

How do I activate anaconda after installation?

Starting NavigatorFrom the Start menu, search for “Anaconda Navigator” and click to open. Or from the Start menu, search for “Anaconda Prompt” and click to open. In Anaconda Prompt, type in anaconda-navigator and press Enter to open Navigator.

How do I launch anaconda in terminal?

Windows: You'll find Anaconda Navigator in the Start menu. Linux: Open a terminal window and run the command anaconda-navigator .

How do I enable Python in anaconda prompt?

Click Start�All Programs�Anaconda (64-bit)�Anaconda Command Prompt. � A command prompt window will open. Type idle to run the Python interpreter. A new window titled Python Shell will open and you will see the Python >>> command prompt.

How do you activate conda environment or code?

You can manually specify the path to the conda executable to use for activation (version 4.4+). To do so, open the Command Palette (Ctrl+Shift+P) and enter Preferences: Open User Settings. Then set python.condaPath , which is in the Python extension section of User Settings, with the appropriate path.


1 Answers

The easiest fix is to just put /Users/mylaptop/anaconda in your PATH, by adding something like

export PATH="/Users/mylaptop/anaconda:$PATH"

to your bash profile (~/.profile).

You can't put the activate script in a script because it has to be "sourced" to work. source causes the script to be run in your current shell (as opposed to a subshell, which is how the bash script you wrote is run). This is necessary because it modifies your PATH environment variable, and environment variables from your current shell cannot be modified by subshells.

like image 60
asmeurer Avatar answered Sep 30 '22 16:09

asmeurer