I have installed Anaconda 2.2.0 for Windows and created a virtual environment via:
> conda create -n my-env anaconda
The environment is sucessfully created and I see it in my list of envinronments (and indeed the directory is there in Anaconda\envs..)
> conda info -e
# conda environments:
#
my-env D:\Anaconda\envs\my-env
root * D:\Anaconda
However, when running the activate.bat script to switch envinronment, although it appears to be successful the switch isn't actually made:
> activate.bat my-env
Activating environment "astropy-dev"...
> conda list -e
# conda environments:
#
my-env D:\Anaconda\envs\my-env
root * D:\Anaconda
With the * indicating the active environment.
I have seen some issues with conda activate on Windows but haven't found this sepecific issue.
For further info: I am looking to copy the whole Anaconda package distribution and then install a dev version over one package.
If you are using Powershell, activate currently does not support it. You will need to modify your PATH manually, or else use the cmd shell.
Are you calling activate from within a batch script? Then it should be call activate my-env.
You don't need the .bat. It's just activate my-env.
You command
activate astropy-dev
must be run from the D:\Anaconda directory. Then it should work.
To check, type:
conda info -e
Related
Conda works as expected and activates the base env on every new installation when I run conda in my miniconda prompt. However, it does not activate the base env anymore at when I rerun after installation, I have added paths to system environment and conda activate doesn't work
Don't add miniconda/python.exe to the path. It won't help you, since more sophisticated packages like numpy would also need the paths to the C-libraries. This is exactly what is achieved by activating an environment via
conda activate
in the command shell. (Check PATH before and after.)
For further information read the docs: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment
I used win10 64bit. The problem is that conda seems can not find env name, only env location.
*********************in system cmd*********************
#conda env list
# conda environments:
#
base C:\Users\czk\Anaconda3
py37 * C:\Users\czk\Anaconda3\envs\py37
testnumpy C:\Users\czk\Anaconda3\envs\testnumpy
*********************in Cmder*********************
λ conda env list
# conda environments:
#
base * C:\ProgramData\Anaconda3
C:\Users\czk\Anaconda3\envs\py37
C:\Users\czk\Anaconda3\envs\testnumpy
λ conda activate py37
Could not find conda environment: py37
You can list all discoverable environments with `conda info --envs`.
Above is the output in system cmd and Cmder. Also tried this answer, and without progress.
I also try and failed your answer (also tried comments).
However, here is a workaround:
conda activate C:\Users\<YOUR_USER>\.conda\envs\<YOUR_ENV>
You are using two different installations of anaconda, one in each tool ('system cmd' and 'Cmdr'). You can know this by seeing the path for the base environment is different from each. System cmd points to anaconda in your user folder (C:\Users\czk\Anaconda3), and Cmdr is pointing to the ProgramData folder (C:\ProgramData\Anaconda3).
Here's how you can ensure that all the environments can be activated by name, regardless which installation or console you're using:
Create a .condarc file in your user home directory (if you haven't already).
Add envs_dirs to it, like below. This tells conda where to look up environments by name. See docs on .condarc specification.
envs_dirs:
- C:\ProgramData\Anaconda3\envs
- C:\Users\czk\Anaconda3\envs
I have created an environment for a specific Python version using
conda create --name my_env python=3.6
when I list all the environments using conda env list I get a correct list of environments:
# conda environments:
#
base /opt/anaconda
my_env /opt/anaconda/envs/my_env
Inside /opt/anaconda/envs/my_env/bin/ there is python interpreter, which, as expected, has version 3.6. When I activate the environment
source activate my_env
it successfully activates (i.e. the terminal prompt indicates (my_env)).
However, when I try to check the python interpreter to which I am currently pointing, which python gives me:
/opt/anaconda/bin/python
which belongs to base environment, instead of
/opt/anaconda/envs/my_env/bin/python
which I would expect.
Question: Why did that happen? More importantly, how to change the Python interpreter path to which the environment points? I.e. in this case I'd like which python to point to /opt/anaconda/envs/my_env/bin/python after activating my_env.
You could try:
conda uninstall /opt/anaconda/bin/python
installed Python 3.7.3 and Anaconda and tried to activate it in the Anaconda Prompt.
activate %PATH%
but i get the error
activate does not accept more than one argument
What can I do about it ?
I think you didn't quite understand how conda works.
In conda, you need to first create your own environment. In this case, let's call it my_env.
conda create -n my_env python
Then, you can activate that environment with
conda activate my_env
Also, pay attention that the conda precedes the activate, using activate directly is obsolete.
If you have space in path, please try this
activate "C:\Users\USER\New Project\"
Generally you have to specify the conda env full path.
yes writing your argument in a closed quote worked for me if there is a space in between characters. So here's what I did with my issue:
>>> conda activate "C:\Users\Name\Desktop\sample_project_1\env"
If you use Linux you can start conda with command (assuming that conda was installed # ~/miniconda3/)
source ~/miniconda3/bin/activate
or
source [conda_install_path]/bin/activate
or
source [conda_install_path]/bin/activate base
By default, (base) virtual environment is loaded.
You can switch to a different environment by
conda activate [env_name]
A sorter path is to type directly
source [conda_install_path]/bin/activate [env_name]
As usual, you can avoid re-typing activation commands every time by augmenting the .bash_rc script
So I am used to typing source activate <environment> when starting a python Anaconda environment. That works just fine. But when I create new conda environments I am seeing the message on Ubuntu 16.04 to start the environments with conda activate instead. Besides the errors about how to set up my shell to use conda activate instead, I am still not clear on what is the difference between source activate ... and conda activate ... Is there a reason to change? Does anyone know the difference between these two commands? Thanks.
As of conda 4.4, conda activate is the preferred way to activate an environment. Generally, you won't find too much of a difference between conda activate and the old source activate, except that it's meant to be faster, and work the same across different operating systems (the latter difference makes conda activate a huge improvement IMO).
From the docs, regarding the release of conda version 4.4.0 (released December 2017):
conda activate: The logic and mechanisms underlying environment activation have been reworked. With conda 4.4, conda activate and conda deactivate are now the preferred commands for activating and deactivating environments. You’ll find they are much more snappy than the source activate and source deactivate commands from previous conda versions. The conda activate command also has advantages of (1) being universal across all OSes, shells, and platforms, and (2) not having path collisions with scripts from other packages like python virtualenv’s activate script.
Here is one difference I found. source activate can be used at the beginning of a bash script to load conda environment, whereas conda activate would give me an error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
This makes a huge difference to me since I often submit bash jobs to cluster and source activate is the only way to change conda environment.
Please correct me if anyone can use conda activate in a bash script.
I am not sure who might find this useful, but if
Your terminal lags due to the addition ">>> conda initialize
" in your .bashrc, then you decide to remove it and add anaconda to the path. If that is the case, then "conda activate env_name"
won't work, but "source activate env_name" will work, and then after
that, you can use either source activate or conda activate. If you
close the shell then to activate the environment again use "source
activate env_name"
FYI, removing ">>> conda initialize >>>" from my .bashrc file has
speedup my terminal and it doesn't lag anymore and I just default in
using "source activate env_name"
I have Ubuntu 20.04, conda version : 4.10.3, and conda-build version
: 3.21.5