Source activation for anaconda python environments no longer working (Mac) - macos

The source activate command in conda is suddenly no longer working for me. When I type source activate py3 in my Mac terminal, I get this error -bash: _conda_activate: command not found.
I recently created a new conda environment for TabPy (Tableau python server); I'm not sure if that changed anything. I have checked that the conda environments I'm trying to activate exist by using conda info --envs, here is that output:
# conda environments:
#
base * /Users/applemacbook/anaconda
Tableau-Python-Server /Users/applemacbook/anaconda/envs/Tableau-Python
Server
py3 /Users/applemacbook/anaconda/envs/py3
I already have the following in my bash profile from my initial installation of anaconda awhile ago export PATH="/Users/applemacbook/anaconda/bin:$PATH".
Based on some comments from related threads, here is some additional information:
The output of which conda is /Users/applemacbook/anaconda/bin/conda.
The output of type source is source is a shell builtin.
The output of which activate is /Users/applemacbook/anaconda/bin/activate.

Related

I have added conda and python path to the environment variable, but jupyter notebook is still not getting opened from cmd

I was trying to add conda and python to the environment variable using SETX Command from CMD but it was failing. I tried setting it using PowerShell and it worked. The path was added successfully but I still can't open Jupyter Notebook from my cmd.
Adding Python to the environment path is bad practice, see Anaconda FAQ. If you haven't installed Anaconda with it's default settings, you first need to:
Initialize your shells
conda init --all
After this you should have ../Anaconda3/condabin only in your path (more information via conda init --help).
But before you can run Jupyter, you also need to activate Anaconda:
C:\> conda activate
(base) C:\> jupyter notebook
The activation will add the following folders of the conda base environment to your PATH:
\Anaconda3;
\Anaconda3\Library\mingw-w64\bin;
\Anaconda3\Library\usr\bin;
\Anaconda3\Library\bin;
\Anaconda3\Scripts;
\Anaconda3\bin;
The python.exe resides in Anaconda3, jupyter.exe in Anaconda3\Scripts, so it's not enough to just add the first folder to your Path. And it's especially important to have the libraries on your Path when you want to run C-based packages like numpy.
But the very point behind the conda activate mechanism is that it allows you to configure and run different environments with different versions of python and 3rd party packages that would otherwise conflict, see Managing environmnts.
On top of that you can even install Python from python.org next to your Anaconda distribution, since conda will make sure that they won't interfere.

Why my conda activate does not work though I have a list of conda environments?

I have already created my own environment using conda in linux. When I check conda info --envs, it gives a list of environment like
# conda environments:
#
base * /home1/sriparna/anaconda3
copy_Env_deepgo /home1/sriparna/anaconda3/envs/copy_Env_deepgo
deepgo_2 /home1/sriparna/anaconda3/envs/deepgo_2
deepgo_3 /home1/sriparna/anaconda3/envs/deepgo_3
enzy /home1/sriparna/anaconda3/envs/enzy
parth /home1/sriparna/anaconda3/envs/parth
protein_struc /home1/sriparna/anaconda3/envs/protein_struc
py2 /home1/sriparna/anaconda3/envs/py2
But I cant activate a particular environment. e.g. when I tried conda activate parth it shows
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
Please help me regarding this.
This worked for me:
source {path_to_anaconda}/anaconda3/etc/profile.d/conda.sh
conda activate parth
Conda is not initialized in your shell. Run the following commands in an interactive shell,
conda init
Conda will detect the type of your shell, and write init scripts into the shell's configuration file. (Running it once is enough.)
Detail
Conda updated its environment activation after 4.6.
Quote from conda 4.6 release log
Conda 4.4 allowed “conda activate envname”. The problem was that setting up your shell to use this new feature was not always straightforward. Conda 4.6 adds extensive initialization support so that more shells than ever before can use the new “conda activate” command. For more information, read the output from “conda init –help”
In previous conda, the binaries installed by the default env "base" are exposed into the shell.
After conda init is introduced in conda 4.6, conda only expose command
conda into the PATH. And environment switch is unified by conda activate env-name and conda deactivate on all platforms. But to make these commands work, you have to do an additional initialization with conda init.
Read the conda 4.6 release log for more detail.
I had installed anaconda in Ubuntu VM environment but base was not loading, tried adding the PATH to .bashrc, didn't solve as Conda:not found was error.
Then I solved through:
Press F1>>Terminal: Select Default Profile
You might have available options :
bash
fish
tcsh
xonsh
zsh
powershell
Choose YOUR_SHELL_NAME
Run:
eval "$(/home/mishra/anaconda3/bin/conda shell.YOUR_SHELL_NAME hook)"
#example
eval "$(/home/mishra/anaconda3/bin/conda shell.bash hook)"
Immediately (base) will show

source activate not work for conda, possible issue with PATH, using mac

I have just installed conda and i cannot active my python.
the line of code i am trying is
source activate py27
but i get the error
bash: activate: No such file or directory
the output from
conda info --envs
is
my_root /Users/home/.conda/envs/my_root
py27 /Users/home/.conda/envs/py27
py28 /Users/home/.conda/envs/py28
snpy /Users/home/.conda/envs/snpy
root * /System/Library/Frameworks/Python.framework/Versions/2.7
So i know they are here. but when i type which activate there is no result.
What do i need to do?
In the newer versions of conda, source activate is replaced with a simple conda activate.

Error activating Conda environment in Windows

I was attempting to use anaconda to download tensorflow. I followed the guide character by character. Anaconda downloaded and installed. I used the command:
c:>conda create -n tensorflow python=3.5
which worked, then I used:
c:> activate tensorflow
Which failed to change to a # prompt. So I tried using pip install and got an error message:
'pip' is not recognized as an internal or external command, operable
program or batch file.
Does anyone have any suggestions on how to correct this?
Did you mean to use:
conda create -n tensorflow tensorflow python=3.5
the conda command:
conda install -n <env_name> <package>
translates your code
conda install -n tensorflow pythong-3.5
tells conda to:
- create a new environment,
- that you want your new environment to be named tensorflow, and to
- install python version 3.5 in the environment you just created.
You did not actually tell conda to install TensorFlow.
Personally, I prefer to name my environment, then change into it to install packages:
conda create -n new_env_name python=3.5
source activate new_env_name
conda install tensorflow numpy pandas matplotlib
* Note: if you are on Windows, you may need to use activate my_env_name instead of source activate my_env_name to start your environment.
Which command to use is dependent on what terminal window you are using:
- Powershell requires activate my_env_name,
- Git Bash requires source activate my_env_name.
Often instructions naively state the the former is always used when on a Windows system.
Try source activate tensorflow.
On mac and in some windows environments source activate <env_name> is required. activate <env_name> is used instead in some Windows' environments.
For example, on Windows, if you're in a Git Bash terminal window, you must use source activate <env_name>, but if you're in a Powershell terminal window, then activate <env_name> would be required.
Linux/Mac will always (so far as I know) require source activate <env_name>
Run Anaconda Prompt as an administrator
I just have the same problem and by this way it's fixed.

Spyder does not run in Anaconda virtual environment on Windows 10

This is my first post here. I tried to find an answer to this question but to no avail.
Just installed Anaconda2 (2.7.11 Python kernel) on my Win10 machine. I am trying to learn the conda command. Here is my problem.
I go to the Anaconda prompt window.
I create a virtual environmant with conda create -n myenv python=3.4 command.
I activate the environment with activate myenv.
When I list the environmants with conda env list it shows as active (star next to it).
When I start python from a command line it shows me that it is running 3.4.
The same with ipython.
When I type spyder it opens the spyder window but shows me 2.7.11. This is confirmed by running print(sys.version).
Am I doing anything wrong or is this just windows 10 problem.
Thanks in advance,
Andy
When you type spyder, the search for this command begins in the paths that the conda environment created. If it cannot find it there, it will go and search at other places. In your case in the paths of the default Anaconda install. So after you activate your environment:
activate myenv
you need to install sypder inside this environment:
(myenv) conda install spyder
where (myenv) indicates the active environment.
Change the Python interpreter in the Preference menu. See pic below.
you just have to write
conda create -n myenv python=3.4 spyder
conda activate myenv
spyder
and for deactivation later on ..
conda deactivate
Note: using Windows 10.
To use Spyder in a particular environment, there are at least two options:
conda install spyder into that environment - the problem, for me, is that it also wants to install a large number of other packages that I don't want or need in that environment.
I just want to use Spyder for interactive programming/investigation using the particular packages that I have chosen to install in a particular environment. The solution to this is option 2.
Note: I installed Anaconda initially and so have Spyder in the Anaconda environment.
Copy the relevant Spyder files from the Anaconda environment into the particular environment(s) you want to use Spyder in:
From: C:\Users\User\Anaconda\Lib\site-packages
Copy: spyderlib & spyderplugins Folders
To: C:\Users\User\Anaconda\envs\[Environment_Name]\Lib\site-packages
From: C:\Users\User\Anaconda\Scripts
Copy: spyder.exe, spyder.ico, spyder_light.ico & spyder-script.py Files
To: C:\Users\User\Anaconda\envs\[Environment_Name]\Scripts
To use Spyder in the desired environment:
Activate the environment
(Environment_Name) prompt> spyder
This works for me!

Resources