Starting with anaconda on Ubuntu 18.04 - python-3.x

I installed latest version of Anaconda3-2020-02.
I was trying to follow this instruction in order to create environment for running with python==3.6 instead of python==3.7., because I have python 3.6. installed.
So, running the
conda create --name snakes python=3.6
and then activating my environment with conda activate snakes, it enters environment (snakes). However there are no anaconda packages inside like jupyter notebook or others, no anaconda-navigator... So whats the purpose of it and how can I run these programs from environment?
Also, for some reason (when I am not in the environment, just regular bash shell) $PATH is not set up to the /bin directory in anaconda, just to /condabin. Can you explain this also, because I am not able to run nothing except conda command from shell after recommended installation.

If by default after installation environment is not activated, you should activate it by sourcing a file anaconda3/bin/activate. You will see indicator (base) on the left of your bash prompt.
Good thing about anaconda3-2020-02 is that it is not messing with system python, as newest python is being launched inside environment and proper$PATH is set up just inside environment. If only, for some reason, specific version of python is needed, then it makes sense to set it up with this instruction. I would be just using default one with python 3.7 probably from (base) environment.
Keep in mind that by default anaconda components are not being set up inside new environment being created. In order to bring them, for example jupyter, you should run the command like this:
conda create --name snakes python=3.6 jupyter

Related

`conda activate <environment>` on Spyder console not working

I have python 3.7.10, conda 4.12.0, and Spyder 5.0.5 installed on Windows 10, and I can see the list of environments with conda env list.
However, when I run conda activate <environment>, CommandNotFoundError appears:
In[1]: conda activate <env>
Note: you may need to restart the kernel to use updated packages.
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.
[...]
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
I like to change the environment without running Anaconda navigator (or close Spyder every time I change the environment).
Is there a command that I can run on Spyder console to change the virtual environment? Is it also possible to run different environments on different Spyder consoles?
To change environments you will need to change the interpreter preference and restart the console or create a new one. To change the interpreter preference you can go to Tools > Preferences > Python Interprer > Use the following Python interpreter and select there the path for the python.exe of the env you want to use.
For more info regarding how to use existing enviroments with Spyder: https://docs.spyder-ide.org/current/faq.html#using-existing-environment

Can't change virtual environment within Azure ML notebook

For some reason the jupyter notebooks on my VM are in the wrong environment (ie stuck in (base)). Furthermore, I can change the environment in the terminal but not in the notebook. Here is what happens when I attempt !conda activate desired_env in the notebook:
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'.
# conda environments:
#
base * /anaconda
azureml_py36 /anaconda/envs/azureml_py36
azureml_py38 /anaconda/envs/azureml_py38
azureml_py38_pytorch /anaconda/envs/azureml_py38_pytorch
azureml_py38_tensorflow /anaconda/envs/azureml_py38_tensorflow
I tried the answers here (e.g., first running !source /anaconda/etc/profile.d/conda.sh).
I also tried activating the environment using source rather than 'conda activate': !source /anaconda/envs/desired_env/bin/activate. This runs but doesn't actually do anything when I see the current environment in conda env list
Edit: also adding that if I install a package in the (base) environment in the terminal, I still don't have access to it in jupyter notebook.
I'm the PM that released AzureML Notebooks, you can't activate a Conda env from a cell, you have to create a new kernel will the Conda Env. Here are the instructions: https://learn.microsoft.com/en-us/azure/machine-learning/how-to-access-terminal#add-new-kernels

I don't understand the error I get while activating environment in Anaconda

I reinstalled Miniconda (version 4.3.21) at c:\Miniconda3, created an environment named data and also installed some packages in this environment. The Python version came with this Conda is 3.6. However, before installing the Miniconda, version 3.4 of Python was already installed on my system (location c:\python34). OS is Windows 7 (32 bits).
On command line, I can run command like conda info --envs or conda create -n data. I can even open Python IDLE by running idle command which opens the IDLE for Python which came wih Miniconda. But when I try to run activate data, it shows this error.
However, when I run command line as administrator, I am able to activate environment. If I remember correctly, earlier I was able run all commands without needing any admin privileges. Why does this happen?
So what is happening is that your user likely has the original Python executable(or old Miniconda Python) in your users PATH and this is found before Minconda Python. When run as Admin(because installing to C:\Miniconda requires admin privileges) it finds the correct executable that is in the System PATH. Having both a standard Python and Miniconda in your user Path will cause issues as it will use the first Python.exe found based on your PATH.
Check Computer > Properties > Advanced System Settings > Environment Variables.
Put Minconda before the standard Python or remove the standard python(there is no difference between standard python and the python included with Miniconda as they both come from python.org). You may also need to set the permissions on the entire C:\Miniconda directory for your user. Even though you have admin access you will still need to escalate privileges if you don't set permissions for your actual user.

Anaconda -- conda create results in "Failed to create process"

I recently installed Anaconda onto my laptop and I am trying to install a conda environment called pydecal that uses python 3.5. I have tried this in CMD as well as in Anaconda Prompt. I did not enter Python when Below is my code:
conda create --name pydecal python=3.5
I am getting a "Failed to create process." message every time I try to run the command. Anaconda installed fine in 64-bit. I am on a clean install of Windows 10. I have no other instances of Python on my computer whatsoever. I have tried running CMD and Anaconda Prompt as an administrator. I have restarted my laptop several times. Regardless, I run into the same problem. Any ideas on what is going wrong?
Did you install it on the primary drive (C:)?
My conda did not work either. I have just uninstalled Anaconda3 which was formerly installed in a secondary drive (E: rather than C:).
After installing Anaconda3 on the primary drive (C:), conda seems to work fine.
I solved it by making this way:
1: Install Anaconda in a directory structure not containing spaces.
2: Modify system environments to not include %PATH% in the user section.
I found that 'echo %PATH%' in a prompt resulted in the system defined paths, were shown twice.
3: Moved all paths containing %SYSTEMROOT% to the top search order. This was to assure the need to search obscure named paths was not searched by the 'activate' command.
Let me know if this solves your problem.
Br Michael
I solved it this way:
Opening the "Anaconda Prompt" Console Link that Anaconda creates in the start menu. As conda appeared to work fine there I copied the predefined envinronment variables for that prompt :
If you check the link, it executes this:
%windir%\System32\cmd.exe "/K" C:\tools\Anaconda3\Scripts\activate.bat C:\tools\Anaconda3
and that file refers to C:\tools\Anaconda3\condabin\conda.bat
So finally the path is specified there as :
C:\tools\Anaconda3;C:\tools\Anaconda3\Library\mingw-w64\bin;C:\tools\Anaconda3\Library\usr\bin;C:\tools\Anaconda3\Library\bin;C:\tools\Anaconda3\Scripts;C:\tools\Anaconda3\bin;C:\tools\Anaconda3\condabin;
I added that to the Windows System Environment variables and it now works properly on git bash, and other shells.
pip install pathlib
that is what i did now everything works

Windows 7: What PATH to set to when using Conda

I've got anaconda installed and was able to create a Python 3.3 environment. I can switch to it and conda info -e shows that I've switched.
However, I'm confused about what to set my PATH variable to. If I hard code it to the exact env then it works, but I thought that the purpose of conda was to be able to switch easily, as well as update and maintain various environments separately.
Perhaps I misunderstood and there's no way around setting my PATH everytime...
In the Windows cmd shell, use the activate and deactivate commands to change the PATH automatically. For instance, if your environment is called python3, run python3 to "activate" (i.e., add to the PATH) the python3 environment. Use deactivate to remove it.

Resources