I am using miniconda 4.5.1 on 4.13.0-37-generic GNU/Linux
I am also using tmux, if that's useful.
When I activate my environment by running source activate ___
conda fails to set up the paths, meaning my python and pip commands are still mapped to the conda regular (or whatever the name is) python commands, not those from my environment. I get the (env-name) tag before my terminal prompt, as though it has been activated.
I have to activate, then deactivate, then reactivate, to force this to happen, using the following commands:
source activate envname
source deactivate
source activate envname
Any clue as to why this might be happening? Thanks!
Related
I'm using VScode on windows, and the VScode terminal.
I installed virtualEnv (with >>> pip install virtualenv )and everything was working correctly.
Then I installed git, and after this, I couldn't deactivate the virtual environment and I don't see any errors too!
I use this command:
MyVirtualEnvName\scripts\deactivate
my problem is: now I can't deactivate virtualenv and the above command isn't working! how can I deactivate this?
try just deactivate in the shell, instead of the path to the deactivate script
Go inside Scripts folder by running cd command.
Then just type deactivate.
It will recognize and will run the deactivate.bat file.
I have activated the conda environment at first and then I have tried to activate the venv created by python3s' native virtualenv package without deactivating the conda environment. To my surprise both the venv are in running state. But python used by the venv is the one which I have activated recently. Can any one explain what is happening here ?
~$ which python3
/usr/bin/python3
~$ conda activate py369
(py369) ~$ which python
/home/xxx/anaconda3/envs/py369/bin/python
(py369) ~$ source venv/bin/activate
(venv) (py369) ~$ which python
/home/xxx/venv/bin/python
(venv) (py369) ~$
If this is like both the venv's are activated then Am I able to access both the packages from conda env and also the venv?
This is what is happening:
You activate the conda environment. conda then modifies your PATH such that /home/xxx/anaconda3/envs/py369/bin is first. You can check this with echo $PATH. It also modifies your shell prompt such that (py369) is displayed in front
You activate your virtualenv environment. Since virtualenv is oblivious of what conda does, it simply modifies your PATH such that /home/xxx/venv/bin/ and puts its own prefix in front of your shell prompt
So now, when you call python, it will be started from the virtualenv folder. When you import packages, they will be loaded from what is installed inside your virtualenv. So you cannot just import from both the conda and virtualenv environment at the same time.
You also have not mentioned why you would want to have such a set up. My personal opinion is that you should not mix different environment programs, as it will only generate confusion.
So I am using vscode with conda (for a django project), and trying to activate my virtual environment named "venv".
And it goes from:
(base) C:\Users\User\Desktop\pfa-master\pfa-master\venv\Scripts> .\activate
to something like this:
(venv) (base) C:\Users\User\Desktop\pfa-master\pfa-master\venv\Scripts>
And if I try to find out Python version, it shows error like this:
(venv) (base) C:\Users\User\Desktop\pfa-master\pfa-master>which python
'which' is not recognized as an internal or external command,
operable program or batch file.
Note: I have Python in environment variables for anaconda.
What am I doing wrong?
You need to deactivate Conda. In terminal, conda deactivate should get rid of (base). When you want to reactivate Conda, conda activate.
You have two virtual environments active.
conda and virtualenv are both package manager and environment management system :
(base) is from conda : https://docs.conda.io/en/latest/
(venv) is from virtualenv : https://virtualenv.pypa.io/en/latest/
If you want to use (venv) only, you need to deactivate conda : conda deactivate
If you want to use (base) only, you need to delete the venv directory from your repository :
sudo rm -rf venv. Command differs because you are using Windows.
Use the command python -V to find the installed python version and pip -V to get the current pip version.
if you have anaconda in your environmental PATH, try activate venv. Also, try restarting VScode sometimes it glitches.
first you can use activate to activate venv, and then use conda deactivate to deactivate (base).
Try this command:
python --version
I'm using pyenv to manage my python environments. One of the environments is anaconda with multiple environments.
There are two ways to activate a conda environment while everything is handled by pyenv.
Load the conda environment directly with pyenv as pyenv local anaconda3-2019.10/env/myenv
Load the main conda and then activate the local environment pyenv local anaconda3-2019.10; conda activate myenv
Both methods fail one way or another:
In the first method, conda command cannot be used to install any more modules as it says command not found
In the second method, the conda activate fails, complaining about the shell: CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. Configuring the shell ruins all the environments by changing .zshrc which is global
I can use pip to install packages but the whole point of using anaconda is to use the nice package managing environment
Have I set something wrong or is this some sort of bug?
I'm having a lot of trouble setting up a virtual env in atom. I tried installing atom-python-virtualenv and I'm trying to use configure script, but it still says "no virtualenv" at the bottom of the atom editor. How can a select or make a virtualenv for atom?
I'm not sure how to make the environment from Atom itself but you can make your virtual environment from the command line by typing
conda create -n myenv python=3.6
where 3.6 can be changed to whatever version you have installed and myenv is a name for your environment. You then activate the environment by typing
conda activate myenv
Now you can run Atom from this environment. Directions concerning virtual environments are located here and here