Home > database >  Get a fresh bash without conda
Get a fresh bash without conda

Time:10-08

is there a way to easily switch from conda environments to my system's native python environment? When I have conda activated, and I run bash or exec bash it doesn't seem to work, and when I run python it uses conda's python and it's not using the system python path. The only way I've been able to get this to work is by restarting the terminal entirely. Is there a faster way to do this?

(I've actually removed the conda init block from my ~/.bashrc and I run it manually every time I want to use conda's python.)

CodePudding user response:

The conda command you're looking for is deactivate.

Suppose you have activated the myproject environment.

$ conda deactivate

Now your environment is base, as seen by which python, or conda info --envs.

$ conda deactivate

Now you're not using conda at all, and which python shows the system interpreter, likely /usr/bin/python.

CodePudding user response:

You have two options:

  1. Just deactivate the base environment:
(base) $ conda deactivate
$ 
  1. Configure your conda to not activate the base environment on startup.
(base) $ conda config --set auto_activate_base false

<restart shell>

$ 

# use the system python
$ python

# to use conda you'll need to activate it first
$ conda activate
(base) $ python

CodePudding user response:

This may be a bit of a hack, but what about adding an alias pointing to the system python before the conda block in .bashrc? Assuming you don't want to use "conda deactivate" and lose the environment completely.

alias syspython=`which python`

# >>> conda initalize >>>
...

You should then be able to use the system python in a conda env like so:

syspython file.py ...
  • Related