Reinstalling Anaconda on Linux - lmmx/devnotes GitHub Wiki
Python can be a fragile thing, and sometimes the easiest solution to a botched implementation is just to reinstall.
(At time of writing I'm doing so because libraries that were working previously are segfaulting)
-
Reminder: this is just an installation of a managed set of programs
- such that
which python
⇒/home/yourusername/anaconda3/bin/python
conda is the package manager. Anaconda is a set of about a hundred packages including conda, numpy, scipy, ipython notebook, and so on.
- such that
Here's a guide to reset your Python [anaconda3] installation, reinstalling this managed set of packages, which will hopefully restore it to proper working order
Before uninstalling Anaconda
- the obvious: don't delete directories containing work you're doing on package development, etc.
- you may want to make a list of all packages you've installed
- to do this, list your environments and then export their package list [as YAML]
- you should note the installation directory for reinstallation (though you can change it)
- the default is
~/anaconda3
- the default is
conda env list
- I have one for example called (creatively) "
my_rdkit_env
" [used with rdkit for chemoinformatics] - I also have what appear to be default ones called "
_build
" and "root
"- the root one is not associated with an environment, but rather across the entire anaconda installation, i.e. the
export
command exhaustively lists all packages you [pip-]installed onto the anaconda installation
- the root one is not associated with an environment, but rather across the entire anaconda installation, i.e. the
- I just went with exporting them using the same names, and adding a .environment to the filename [before the filetype suffix], but obviously do as you like
conda env export -n my_rdkit_env > my_rdkit_env.environment.yml
conda env export -n root > root.environment.yml
conda env export -n _build > _build.environment.yml
- in case you're wondering what these
export
commands produce, the YAML [e.g. here, for theroot
environment] will look something like this:
name: root
channels: !!python/tuple
- defaults
dependencies:
- abstract-rendering=0.5.1=np110py35_0
- alabaster=0.7.6=py35_0
…
- yaml=0.1.6=0
- zeromq=4.1.3=0
- zlib=1.2.8=3
- pip:
- autopep8==1.2.1
- backports.weakref==1.0rc1
- biopython==1.66
…
- websocket-client==0.37.0
- xonsh==0.2.3
- xonsh-kernel==0.2.0
prefix: /home/louis/anaconda3
...
-
Michael Waskom [developer of seaborn] notes that Anaconda will add a line modifying your system PATH onto
~/.bash_profile
- but it may have done so in
~/.bashrc
, - or like me you may have decided to split up this file into categorised files which are then sources
- but it may have done so in
-
the docs recommend to remove the line from
bash_profile
adding conda3 to the PATH variable, and delete its dot files (~/.condarc
,~/.conda
, and~/.continuum
)
After this, just go through the initial installation process (also, Python will now be back to the 'system Python': for me that's /usr/bin/python
)
Then just download the latest version of Anaconda for your system and run the bash installer, simple.