running source activate <env> in Anacaonda Promt fails - anaconda

There are already many posts describing how to solve 'source' is not recognized as an internal or external command," by adding anaconda to path.
Following the recommended approach is to not check the box to add Anaconda to your path.
How can i start my env from the Anaconda Promt?
conda 4.6.11
conda env list show my env's

conda activate environmentNameHere in the Anaconda terminal will do it. If you want to deactivate an environment you just type conda deactivate

Related

Switch from Pyenv to Conda

I've been using pyenv but I want to switch to Conda. I use VScode, managed to create a Conda environment and use the proper version of Python but when installing packages with PIP, they still install on pyenv and not conda, how do I change that? Should I just remove pyenv from my computer or can I just change the path for pip?
Not sure if that'll help but I did an echo $PATH and got this list
/opt/homebrew/Caskroom/miniforge/base/condabin:/Users/marc/.pyenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Marc, it is not clear from your question whether you've configured conda correctly for VS Code, which means
setting the default terminal
ensuring the default terminal is correctly reading ~/.profile args
ensuring you can select your miniforge conda env from list of python interpreters.
More details about ensuring conda is configured properly is in this related stackoverflow post.
Finally, please ensure that you pip install inside the activated conda env? This is obvious.... for sanity sake ensure you can see the env activated at the shell prompt inside your VSCode terminal before doing pip / conda install commands. Running which pip at the prompt should confirm that you are using pip inside the miniforge path.

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.

conda not recognized as an internal or external command

I've installed Anaconda and now I want to create a conda environment,
C:> conda create -n tensorflow pip python=3.5
but then I get the error that "conda" is not recognized as an internal or external command.
How can I fix this?
As Windows user you have to start a Anaconda Prompt from the start menu. Look in your start menu for anaconda3-64bit -> anaconda prompt.
Now the conda command should be found in this shell.
Otherwise add the Anaconda Binaries folder to your environment path.

Anaconda Environment in prompt/PS1 in MacOS?

When I was in Ubuntu installing Anaconda and activating a virtual environment modified my prompt to look like that:
(current-env)user#machine:dir
or as you define in .bashrc.
Now that I installed Anaconda in MacOS my prompt remain the same. I tried to configure that from Anaconda doing:
conda config --set changeps1 no
but nothing changed.
How can I modify my .bash_profile to have the current environment in PS1?
I managed to have that changing my shell from bash to zsh.
You can install zsh from here.
In recent versions, Conda has provided automated configuration for a number of shells via the conda init command. This command will edit relevant .*rc files to enable such features of PS1 change. Please see conda init --help for details.

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