I'm building a website with Django. I built a Django virtual environment with anaconda. A few days ago I have updated the anaconda and after that, I have a problem with activating a virtual environment
When I trying to activate a virtual environment with source activate django, the terminal responds with this message:
Could not find conda environment: django
You can list all discoverable environments with `conda info --envs`.
where apparently there is a virtual environment name 'django'.
When I try conda info --envs on a terminal, it shows:
WARNING: The conda.compat module is deprecated and will be removed in a future release.
# conda environments:
#
/Users/myname/anaconda3/envs/django
base /anaconda
I can't see the first one's name but only directory. However, if I open anaconda navigator and see the list of virtual environments, I can see the environment name 'django', and can activate it with a play button. Also, I can see one more environment name 'anaconda3' which is not even displayed on a terminal by command conda info --envs.
Is there any possible reason for this?
Related
Whenever I create a new Tmux session it's activated automatically with base. When I do conda deactivate then it shows that another environment is activated.
For example:
(base) user#something: conda deactivate
(env1) user#something:
when it used to not show anything.
When I run conda env list it shows:
# conda environments:
#
env1 /home/user/.conda/envs/env1
env2 /home/user/.conda/envs/env2
base /usr/local
So something tells me that the base is set incorrectly. How do I fix this behavior?
I tried to using conda to install tensorflow, but conda show an ProxyError when shadowsocks opening. Though I have configured the proxy_servers in .condarc with the http:\\localhost:port, it did not work. Meanwhile, the direct mode didn't work too. Only I turn off the Shadowsocks, can conda link to channels.
Hers is the Error Message.
ProxyError: Conda cannot proceed due to an error in your proxy configuration. Check for typos and other configuration errors in any '.netrc' file in your home directory, any environment variables ending in '_PROXY', and any other system-wide proxy configuration settings.
How can I use conda normally without turning off shadowsocks?
I have multiple conda environments on my PC created with Anaconda and I have installed jupyterlab in two of them. I used one environment for R programming and the other for Tensorflow with Python. I have noticed that whenever I open jupyter lab in either of the environments, it always starts off where I left it. That is, the last open notebooks are opened on start. Of course, this doesn't bother me too much, but it makes me think each jupyter lab installation isn't contained within its own environment.
For example, I have two environments. Say they're called env_R and env_Python_TF. I have installed jupyter lab in both environments.
I open Anaconda Powershell prompt and launch each environment using the following commands:
(base) PS $ conda activate env_R
(env_R)PS $ jupyter lab
Say I work on jupyter lab and once I'm done, I close the browser windows and then shut down the server using CTRL+C in Anaconda Powershell prompt. Now if I open up my second environment using:
(base) PS $ conda activate env_Python_TF
(env_Python_TF)PS $ jupyter lab
Now I see the same notebooks I used with env_R opened up when jupyter lab opens in my browser.
Aren't each jupyter lab installation contained within its own conda environments? If not, have I possibly made a mistake in my configuration?
it should be within its own conda environment but Default root folder /location will remain same for jupyter notebook. You will need to change it using config file.
Here is link
We've just migrated from windows7 to windows10 and had a lot of conda environments associated with each their own experiment.
The envs all exist in, say, F:\backup\<experiment_name>\conda\envs\ and as they were created with conda, conda had them registered. Now - with fresh installs of Anaconda3 we've lost the ease of access from conda as conda info --envs only returns:
D:\>conda info --envs
# conda environments:
#
root * D:\bin\anaconda3
What's the easiest way to get the old envs listed as if they were created with conda? There must be a register somewhere that I could update...?
You can add the backup path to envs_dirs in your .condarc config file.
It can be done with:
conda config --append envs_dirs F:\backup\<experiment_name>\conda\envs\
Or just with a manual edit of the file (it's YAML)
envs_dirs:
- D:\bin\anaconda3\envs
- F:\backup\<experiment_name>\conda\envs\
See the official doc for more details.
In my Anaconda installation on Windows 7 there is a file C:\Users\MYUSERNAME\.conda\environments.txt which contains a plain-text list of the paths of all my environments.
If I create a renamed duplicate of one of these environment folders (say to mynewenv) and edit the new path into the environments.txt file, it appears in the output from conda info --envs and I can successfully (as far as I can tell from a quick test) activate the new environment with activate mynewenv.
That may be enough to sort you out, but if there's anything about the old environments that still isn't registered properly then you should be able to export the environment contents to a .yml file and create a brand new copy by specifying that file to the conda env create command.
Is it possible to start an ipython shell(in terminal) within a conda or virtualenv ?
The ipython shell should belongs to the respective environment.
I know a way to start jupyter notebook within the env, by creating a kernelspecs for the virtual env and then choosing the env kernel within the jupyter notebook.
here is the link : http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs
But this only setup the jupyter notebook for the current environment. Is there a to do the same for ipython shell
The answer given by Grisha Levit almost solved the problem. So, i am writing the complete details of the answer, how to setup a ipython console within a specific environment.
1.) Activate the virtual env:
source activate <environment-name>
2.) From within the virtual env:
jupyter kernelspec install-self --user
3.) This will create a kernelspec for your virtual env and tell you where it is:
Installed kernelspec pythonX in home/username/.local/share/jupyter/kernels/pythonX
Where pythonX is the version of the python in the virtualenv.
4.) Copy the new kernelspec somewhere useful. Choose a kernel_name for your new kernel that is not python2 or python3 or one you've used before and then:
mkdir -p ~/.ipython/kernels
mv ~/.local/share/jupyter/kernels/pythonX ~/.ipython/kernels/<kernel_name>
5.) If you want to change the name of the kernel that IPython shows you, you need to edit ~/.ipython/kernels//kernel.json and change the JSON key called display_name to be a name that you like.
6.) Running jupter/ipython console within the virtualenv.
jupyter console --kernel <kernel-name>
7.) This will start the jupyter console/shell for the current virtualenv and you can also see kernel in the IPython notebook menu: Kernel -> Change kernel and be able so switch to it (you may need to refresh the page before it appears in the list). IPython will remember which kernel to use for that notebook from then on.
I know a way to start jupyter notebook within the env, by creating a kernelspecs for the virtual env and then choosing the env kernel within the jupyter notebook.
You just need to do the same thing, but using console instead of notebook.
For example:
ipython console --kernel python2