Skip to content

Instantly share code, notes, and snippets.

@ibressler
Last active November 29, 2023 15:10
Show Gist options
  • Save ibressler/b9139ca80346eefd7550fbfee2fbd47a to your computer and use it in GitHub Desktop.
Save ibressler/b9139ca80346eefd7550fbfee2fbd47a to your computer and use it in GitHub Desktop.
Setup Python on Windows for unprivileged non-admin users, replacing Anaconda

Setup Python on Windows for unprivileged non-admin users and replacing Anaconda

  • Uses a recent Miniforge including mamba and the conda-forge channel and is a recommended replacement of the Anaconda distribution which ships a buggy and unreliable package manager (conda)
  • side-effect: Its published under BSD-style license, no trouble with individual vs. corporate use

Install mamba

  1. Download the latest installer from the releases page. The windows installer is often hidden behind the show all assets button and the file name should be something like Miniforge3-x.y.z-1-Windows-x86_64.exe.
  2. Installation should work for an unprivileged user inside their user directory or in the AppData\Local subdirs, for example. In tests it worked with anti-virus enabled but this depends on the restrictiveness of the AV settings, of course.

Example running jupyter lab

  1. Open the newly installed miniforge prompt and create a new environment (as described here):
    mamba create -n jlab jupyterlab -c conda-forge
    mamba activate jlab  # activate our environment
    
  2. Quick&dirty shortcut for opening jupyter lab, assuming miniforge was install in the users home dir:
  • Executable path: .\miniforge3\condabin\mamba.bat
  • Working directory: %HOMEPATH%
  • Command line arguments: run --live-stream -n jlab jupyter lab

Install GIT

With conda/mamba

  • install it from conda-forge repos, as described here
    mamba install -c conda-forge git
    

Install GIT, independently

  1. Download the latest MinGit package from the release page
  2. Extract it to a folder in the users home dir, AppData\Local\MinGit, for example.
  3. Create a shortcut (.bat file) for a Terminal with Git support:
    @echo off
    set GH=%HOMEPATH%\AppData\Local\MinGit
    set PATH=%GH%\cmd;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
    cmd /Q
    
  4. Make Git available in miniforge environments by putting a similar file (just without the cmd call) in the activation scripts folder %HOMEPATH%\miniforge3\etc\conda\activate.d:
    @echo off
    set GH=%HOMEPATH%\AppData\Local\MinGit
    set PATH=%GH%\cmd;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
    

Install a Python IDE

  • such as PyCharm, Community Edition, works fine out of the box.
  • Set the conda environment for the current project under Settings->Project->Python Interpreter->Conda Environment and point it to %HOMEPATH%\miniforge3\condabin\conda.bat and select the environment from the drop-down list.
  • The embedded Terminal can be set independently to a conda environment by using the following command for the Shell path under Settings->Tools->Terminal:
    cmd /k %HOMEPATH%\miniforge3\condabin\mamba.bat activate jlab
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment