I have problems creating a new Anaconda environment. I am new to Python and Anaconda and in another thread (Customize axes in Matplotlib) I was asked to create an new environment because apparently I was using an old version of some packages (Pandas, Matplotlib and also from Jupyter).
So I inserted the following comments in the Anaconda prompt:
conda update conda
conda create -n myenv python=3.7
Both of them could be executed without an error and a new environment was created in Anaconda. I was further told to use the following comment:
conda activate myenv
source activate myenv
Both of them lead to error messages. The first one leads to the message "CommandNotFoundError: 'activate'" and the second one to "The instruciton source is either spelled wrong or could not be found" (translated from German). The helping person from the other thread told me to ask this in a separate question because, he or she does not know, what the problem might be. Does anyone of you have an idea.
You version is old. Please update your conda to the latest version. Then conda activate myenv would work. You can update by running the following command in your terminal:
conda update conda
Related
I am trying to install FB's Prophet package to use in Jupyter, which I launch via Anaconda, however I am getting errors with each attempt. I started on FB's Git page and used 'conda install -c conda-forge prophet', however, I continuously get an error that I need to manually a series of files (hijri, ephem, lunarcalendar, etc.). I have researched as many links as I could, including this long exchange on GitHub, but have been unable to find a solution. In my more recent attempts to install Prophet I am just getting a continuous loop of "Solving environment".
I am a relatively new user to Anaconda and not intimately familiar with interacting in Terminal. If anyone can offer insights into what I could be doing differently it would be greatly appreciated.
Please let me know if I can provide any more details. Thank you.
It's always best to create a new environment rather than installing new packages into the base environment - the base env already contains lots of packages so you are liable to hit lots of dependency problems if you introduce anything new as conda tries to figure out what version of every package will be compatible with all the others.
To create a new env called myenv in which you want to use the packages prophet and jupyter (and all their dependencies), and getting the packages from the conda-forge channel, do:
conda create -n myenv -c conda-forge prophet jupyter
To use Jupyter in this environment, just activate the env before starting Jupyter:
conda activate myenv
jupyter notebook
For more information about working with conda environments, see the documentation
I had a conda environment in my PC and yesterday I updated dependencies in that env using the command conda update --env. But when I tried to find Anaconda Prompt in the windows search bar today, that is not showing. I search all the questions regarding this problem on the SO, but many answers were not helpful or with broken links. I'm somewhat new to conda, therefore any helpful suggestion is highly appreciated.
You can toggle between the conda environment as such:
$ conda activate # this will enter the conda shell
$ conda deactivate # this will leave the conda shell
Let me know if you need any more help.
I have quite some problems using python on my Mac. I need different versions from 3.5 to 3.7 and multiple packages for data science. Due to various instructions on the web I ended up installing python 3.6 itself, anaconda, pipenv and maybe more stuff I can't even remember.
I suppose there is no other way to eliminate this mess than to format everything and start over. Currently my terminal is showing some sort of prefix for the environment in the terminal. Something like:
(base) user#machine:~$:
How can I at least get rid of this environment prefix? It appeared after installing pipenv, which seems to have taken over my previous anaconda environments. I fear those vanish to when uninstalling pipenv.
The deactivate command alone will get you out of the currently activated virtual environment.
(base) user#machine:~$:
(base) user#machine:~$: deactivate
user#machine:~$:
As far as I know, this works across all operating systems.
Found the problem: Anaconda edited the .bash_profile which gets executed on the mac for each new terminal. I deleted the anaconda entry and the base prefix is gone.
Also, for anyone that is using zsh and Anaconda.
You can remove the entry Anaconda makes from the ~/.zshrc file in addition to the conda deactivate
Conda can be configured with command conda config
This command will remove message about the current environment:
conda config --set changeps1 no
This command will add messages about the current environment:
conda config --set changeps1 yes
https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#change-command-prompt
After activating my anaconda Python 3.6 environment with
source activate py36
if I type
python
I go into python 3.6, as expected. But if I type
ipython
I go into an ipython environment based python 3.5.5, which is the same python version I get using
source activate base
and then
python
How can I get into an ipython environment using my anaconda-supplied python 3.6 interpreter? I have updated my anaconda environment with
conda update anaconda
and
conda update conda
Doing so does not help.
EDIT:
I hadn't realized that I had to install ipython separately for the python 3.6 environment; I'd thought it was a default part of anaconda. So
conda install ipython
after
source activate py36
did the trick. It doesn't seem optimal that after activating a particular environment, ipython may bring up a completely different anaconda-based environment. I'd prefer it to simply cause a "command not found" error. Bringing up the wrong environment without making it very obvious that that is happening could lead to confusion or problems.
I hadn't realized that I had to install ipython separately for the python 3.6 environment; I'd thought it was a default part of anaconda. So
conda install ipython
after
source activate py36
did the trick.
Have you done hash -r since entering the conda environment? Bash can cache paths to executables, so sometimes it doesn't use the one reported by which. Running hash -r resets the cache
Maybe you need also to update ipython conda update ipython
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