Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Anaconda on Windows Subsystem for Linux (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 (https://github.com/Microsoft/WSL/issues/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_65.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
  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.

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

@Proteusiq

This comment has been minimized.

Copy link

Proteusiq commented Oct 29, 2019

You can always get the latest version:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# yes yes bla bla
source ~/.bashrc
rm Miniconda3-latest-Linux-x86_64.sh
@mcg1969

This comment has been minimized.

Copy link

mcg1969 commented Dec 27, 2019

Great docs! Here is a particularly useful addition that I was able to assemble with a bit of Googling: getting Jupyter to open up directly into the Windows browser. Both of the steps below should be applied within a WSL shell.

  1. Define the BROWSER environment variable. The value of this variable should be the path to the Windows web browser you would prefer to use. For instance, I added this to by .bashrc:
export BROWSER="/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"
  1. Disable the file-based redirect method that later versions of Jupyter use to launch notebook windows, in favor of the older, token-based approach (see jupyter/notebook#4999):
jupyter notebook --generate-config
echo c.NotebookApp.use_redirect_file = False >> ~/.jupyter/jupyter_notebook_config.py

Voilà! You can now use the jupyter notebook command without the --no-browser option—it will launch directly into a Windows browser window.

@danobaji

This comment has been minimized.

Copy link

danobaji commented Jan 9, 2020

Hey!
I recently started using Ubuntu and tried to install Anaconda as you described but when I run the wget line, I get this error:

Will not apply HSTS. The HSTS database must be a regular and non-world-writable file.
ERROR: could not open HSTS store at '/home/danielobaji/.wget-hsts'. HSTS will be disabled.
--2020-01-08 21:14:38--  https://repo.continum.io/archive/Anaconda3-2019.10-Linux-x86_64.sh
Resolving repo.continum.io (repo.continum.io)... 103.224.182.252
Connecting to repo.continum.io (repo.continum.io)|103.224.182.252|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://ww38.repo.continum.io/archive/Anaconda3-2019.10-Linux-x86_64.sh [following]
--2020-01-08 21:14:38--  http://ww38.repo.continum.io/archive/Anaconda3-2019.10-Linux-x86_64.sh
Resolving ww38.repo.continum.io (ww38.repo.continum.io)... 185.53.179.29
Connecting to ww38.repo.continum.io (ww38.repo.continum.io)|185.53.179.29|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2020-01-08 21:14:39 ERROR 403: Forbidden.

I have no idea what this means, any help will be appreciated.

@mcg1969

This comment has been minimized.

Copy link

mcg1969 commented Jan 9, 2020

@danobaji Try changing all of the URLs from repo.continuum.io to repo.anaconda.com and see if that helps.

@RomuloDevelop

This comment has been minimized.

Copy link

RomuloDevelop commented Jan 19, 2020

If someone is getting an error with permission denied when executing jupyter, probably you need to create another folder inside the root and move to that folder, for example: /mnt/c/Users/[USER NAME]/New Folder and run jupyter from there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.