Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Anaconda on Windows Subsystem for Linux (WSL)

Thanks everyone for commenting/contributing! I made this in college for a class and I no longer really use the technology. I encourage you all to help each other, but I probably won't be answering questions anymore.

This article is also on my blog: https://emilykauffman.com/blog/install-anaconda-on-wsl

Note: $ denotes the start of a command. Don't actually type this.

Steps to Install Anaconda on Windows Ubuntu Terminal

  1. Install WSL (Ubuntu for Windows - can be found in Windows Store). I recommend the latest version (I'm using 18.04) because there are some bugs they worked out during 14/16 (microsoft/WSL#785)
  2. Go to https://repo.continuum.io/archive to find the list of Anaconda releases
  3. Select the release you want. I have a 64-bit computer, so I chose the latest release ending in x86_64.sh. If I had a 32-bit computer, I'd select the x86.sh version. If you accidentally try to install the wrong one, you'll get a warning in the terminal. I chose Anaconda3-5.2.0-Linux-x86_64.sh.
  4. From the terminal run wget https://repo.continuum.io/archive/[YOUR VERSION]. Example: $ wget https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
  5. Run the installation script: $ bash Anaconda[YOUR VERSION].sh ($ bash Anaconda3-5.2.0-Linux-x86_64.sh)
  6. Read the license agreement and follow the prompts to accept. When asks you if you'd like the installer to prepend it to the path, say yes.
  7. Optionally install VS Code when prompted (some have reported this installation doesn't work - checkout https://gist.github.com/kauffmanes/5e74916617f9993bc3479f401dfec7da#gistcomment-3665550)
  8. Close the terminal and reopen it to reload .bash configs.
  9. To test that it worked, run $ which python. It should print a path that has anaconda in it. Mine is /home/kauff/anaconda3/bin/python. If it doesn't have anaconda in the path, do the next step. Otherwise, move to step 11.
  10. Manually add the Anaconda bin folder to your PATH. To do this, I added "export PATH=/home/kauff/anaconda3/bin:$PATH" to the bottom of my ~/.bashrc file.
  11. To open jupyter, type $ jupyter notebook --no-browser. The no browser flag will still run Jupyter on port 8888, but it won't pop it open automatically. it's necessary since you don't have a browser (probably) in your subsystem. In the terminal, it will give you a link to paste into your browser. If it worked, you should see your notebooks!

Leave a comment on anything you see that doesn't work and I can look into it!

A few other things that I did out of laziness but aren't necessary

  • made a symlink between my C:/Users/kauff/Documents/JupyterNotebooks folder (where I put my downloaded notebooks in Windows) to my Ubuntu notebook directory: In the WSL terminal:
  1. cd ~
  2. ln -s /mnt/c/Users/kauff/Documents/JupyterNotebooks/ notebooks Now when you look at Jupyter on :8888, you should see a notebooks folder that has everything your C:/Users/kauff folder has.
  3. I made an alias for the juypter command by putting this command in my .bash_aliases: alias jup='cd /home/kauff/notebooks && jupyter notebook --no-browser. Restart the terminal for this new command to take effect.
  4. To test, simply type jup from anywhere in the ubuntu directory and it will take you notebooks folder and run jupyter. When you copy and paste the URL, you'll see everything in your C:/Users/kauff/JupyterNotebooks folder.

Troubleshooting

Thanks to Alexander for the tip: "A note to be made from my installation -- there was an issue with Jupyter that required conda update conda and conda update conda-build. I then uninstalled/reinstalled jupyter with conda to avoid a 500 error for dependencies".

Sources

https://conda.io/docs/glossary.html#anaconda-glossary https://www.cgranade.com/blog/2016/08/22/qutip-on-wsl.html https://jupyter.readthedocs.io/en/latest/install.html

@jschmidt8
Copy link

jschmidt8 commented Apr 24, 2020

I have Anaconda installed on my main Windows 10 System using the *.exe (latest version). I am doing a lot of work on a remote linux station and want to use the WSL to run Anaconda, Jupyter Notebooks, etc. If I install Anaconda on the WSL via these steps, it shouldn't mess up the Anaconda installation on the Windows side should it? Any insight in this regard is appreciated.

@Proteusiq
Copy link

Proteusiq commented Apr 24, 2020

Yes, they are totally separate conda.

@Preeti-Rajpoot-ITD
Copy link

Preeti-Rajpoot-ITD commented Apr 27, 2020

will spyder GUI can be open in ubuntu app on windows?

@aiexplorations
Copy link

aiexplorations commented May 9, 2020

Thank you. Should I have VS Code installed on Windows before installing Anaconda for WSL? I'd expect that WSL won't have permissions for Windows install / config.

@Kartik-Sama
Copy link

Kartik-Sama commented Jul 9, 2020

Thanks a lot for the article. Helped my way through.

@naseem142
Copy link

naseem142 commented Aug 23, 2020

Thank you! great guide

@maulberto3
Copy link

maulberto3 commented Aug 31, 2020

I have Anaconda installed on my main Windows 10 System using the *.exe (latest version). I am doing a lot of work on a remote linux station and want to use the WSL to run Anaconda, Jupyter Notebooks, etc. If I install Anaconda on the WSL via these steps, it shouldn't mess up the Anaconda installation on the Windows side should it? Any insight in this regard is appreciated.

Would love some insight on this. Many users already have Anaconda installed on Windows, so using it through WSL 2 instead of 'double install', would be great.

@renatospaka
Copy link

renatospaka commented Sep 19, 2020

jupyter notebook

Hi @mcg1969, I liked of what you suggested and decided to point my browser to Edge Chromium: export BROWSER="/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"

However, I get this error message in the browser when run jupyter notebook from my ubuntu:

File not found
ERR_FILE_NOT_FOUND

@suzhanhao
Copy link

suzhanhao commented Sep 25, 2020

very very useful guide, Thank you all!

@laisbsc
Copy link

laisbsc commented Oct 19, 2020

Great tutorial :) I'mjust getting in to WSL now and it is so much fun! <3 I had one issue, though.

When you say:

"ln -s /mnt/c/Users/kauff/Documents/JupyterNotebooks/ notebooks Now when you look at Jupyter on :8888, you should see a notebooks folder that has everything your C:/Users/kauff folder has."

I do indeed, but the folder does not allow to cd into it, neither from the CLI or from the Jupyter Notebook on the browser.

@garciadelcastillo
Copy link

garciadelcastillo commented Nov 20, 2020

👍

@Abhi-H
Copy link

Abhi-H commented Nov 22, 2020

Thanks!

@tabitaCatalan
Copy link

tabitaCatalan commented Feb 1, 2021

Super useful! Thanks a lot.

@acmoles
Copy link

acmoles commented Feb 12, 2021

Perfect, thanks!

@raraz15
Copy link

raraz15 commented Feb 24, 2021

Thanks a lot! I encountered some problems while installing packages on conda, so I wanted to write briefly the soultion that I found.

These steps may install python3.7 or even before, and you may need higher versions. If you install a higher python, this will create a problem with conda and you will be forced to delete it. As a solution, you may update conda but then you may face the problem of CondaHTTPError: HTTP 000 CONNECTION FAILED. There are explanations on why this problem occurs but the only solution that I could find was yo use miniconda , because I did not want to use miniconda (no particular reason, just that I do not know much about conda), I find a new solution.

You create a new environment from conda with specifying the python version you want, without updating conda or installing any python. You activate this environment and use pip or conda to install the required packages.

@ShahafEdri
Copy link

ShahafEdri commented Mar 3, 2021

great :-)
is there a way to let ubuntu installed karnel work with the already installed conda and virtual environments on windows, and not reinstall everything again?

thanks
SE

@dsbowen
Copy link

dsbowen commented Mar 15, 2021

Great tutorial!

However, I couldn't install VS code via the anaconda installer. The anaconda installer attempted to install the Linux version of VS code, whereas I needed the Windows version of VS code with the Remote WSL extension.

Here are the instructions that got VS code working for me in WSL: https://code.visualstudio.com/docs/remote/wsl-tutorial

You may want to caution users not to install VS code via anaconda and instead follow these instructions.

@McNickSisto
Copy link

McNickSisto commented Apr 14, 2021

Hey ! Thank you for the great tutorial. However, I have been struggling to switch my PATH even after joining the below line:
export PATH=/home/sisto/anaconda3/bin:$PATH
to my .bashrc file.

I keep on getting this path : /home/sisto/.pyenv/shims/python

If you have any recommendations, I would gladly take it :)

@husseinkorly
Copy link

husseinkorly commented Apr 23, 2021

I was able to install it thru running:

  • wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh to download anaconda and you can always get latest by copying the link from here [https://www.anaconda.com/products/individual#linux](Anaconda Installers)
  • run the installer but don't press too many "Enter" because you don't want to miss this part 😁

image

  • restart the terminal

@Mohamad-Jaallouk
Copy link

Mohamad-Jaallouk commented May 7, 2021

Don't install Miniconda with sudo, otherwise it will be installed in /root directory.

@subramanyakrishna
Copy link

subramanyakrishna commented Aug 1, 2021

Hello, Can I please know how to integrate vscode to this? I have installed vscode and installed remote wsl and python extension but it is not detecting conda environment in the interpreter list .

@husseinkorly
Copy link

husseinkorly commented Aug 2, 2021

Not sure if you tried to click on select interpreter

click1

and then see something like this

click2

@IanThomasICT
Copy link

IanThomasICT commented Aug 4, 2021

Similar to @McNickSisto, I was struggling to manually add the directory to my PATH using the command you provided.

I was able to get the issue fixed by using this notation in ~/.bashrc export PATH=$PATH:/home/{username}/anaconda3/bin

@raghu330
Copy link

raghu330 commented Oct 28, 2021

Thanks Kaufmanes. I have been using WSL2 for the past 1 year and it gives me the best of both worlds. I have my envs setup and everything setup in WSL. But I have one small issue or more like a wishlist.. I prefer using PyCharm as my IDE in windows as it's a decent IDE and gives me clarity.. However, I would like window's version of PyCharm to make use of WSL's python! I tried several ways, but unable to get each of them talk to!! Any ideas!

@sharadlaad
Copy link

sharadlaad commented Oct 31, 2021

Getting error ERR_CONNECTION_REFUSED "This site can’t be reachedlocalhost refused to connect." while opening jupyter notebook URL from windows chrome browser. Do we need to map any port from WL2 to local host?

@natuan310
Copy link

natuan310 commented Nov 25, 2021

Thank you for sharing. I installed successfully but I don't know how to get conda recognized after start a new wsl instance. Need to run "source ~/.bashrc" everytime. Could you tell me what to keep conda auto recognized by wsl?

@AlexanderLavelle
Copy link

AlexanderLavelle commented Mar 11, 2022

A note to be made from my installation -- there was an issue with Jupyter that was giving me a 500 error when I attempted to open any notebooks. To fix:

conda update conda
conda update conda-build
conda uninstall jupyter
conda install jupyter

This worked. Based on a set of solutions on Stack Overflow. Best of luck!

@Ibrarhussainmughal
Copy link

Ibrarhussainmughal commented Apr 1, 2022

I have a issue with during open the environment of anaconda in wsl2
How i can activate environment i have environment but when i try with source environment name /bin/activate
The answer is
1648796649354273860770329608235

@tzdanows
Copy link

tzdanows commented Apr 27, 2022

I managed to get this working with numerous issues along the way but upon opening WSL I need to run source /installrepo/bin/activate, (after the install succeeds) but I now need to run that every time I open WSL, anyone have advice for how to fix this? Might post details on how I managed to get mine working if I can get this resolved.

@CMWolfe922
Copy link

CMWolfe922 commented May 17, 2022

I am trying to use python environments that I already had installed and I keep getting errors saying: ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? Is there a way to fix this? So that I can use both conda environments and my previous python environments I already have built for other projects?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment