Python: Install Python with pip on Windows by the embeddable zip file


to install Python on Windows download the latest version. In this example Python 3.6.5.

Extract the zip file to an directory, e.g. D:\python3.6.5.

To install pip download the latest version of get-pip to the pythons install path and start installation.

d:\> cd /d D:\Python3.6.5
D:\Python3.6.5> python
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-10.0.1 setuptools-39.2.0 wheel-0.31.1

If you are behind a proxy add the –proxy switch

D:\Python3.6.5> python --proxy=""

Unfortunately in the default configuration you can not load any module installed by pip, pip itself too. Because the sys.path variable just contains Python Zip file and the path to the python directory where the python executable is located.

>>> import sys
>>> print(sys.path)
['D:\\Python3.6.5\\', 'D:\\Python3.6.5']
>>> import pip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pip'

Any try to expand the variable by setting a PYTHONPATH variable are ignored. Root cause is that the embeddable zip file installation package contains a file python36._pth which overwrites all other possibilities to set the sys.path variable. sys.path contains all directories where python looks for modules.

To set the sys.path variable open the _pth file an add the following pathes at the and of the file. Replace “D:\Python3.6.5” with your installation directory.


Or rename the python36._pth file

D:\Python3.6.5> ren python36._pth

and set the PYTHONPATH environment variable for the current user.

setx PYTHONPATH "D:\Python3.6.5;D:\Python3.6.5\DLLs;D:\Python3.6.5\lib;D:\Python3.6.5\lib\plat-win;D:\Python3.6.5\lib\site-packages"

or for the whole system

setx /M PYTHONPATH "D:\Python3.6.5;D:\Python3.6.5\DLLs;D:\Python3.6.5\lib;D:\Python3.6.5\lib\plat-win;D:\Python3.6.5\lib\site-packages"

That’s it 🙂


Advertisment to support

15 thoughts on “Python: Install Python with pip on Windows by the embeddable zip file”

  1. Thank you for the instructions, it worked for me.

    Have you tried “virtualenv” or “python -m venv”?

    I got:

    ———–for virtualenv
    D:\projects\test>virtualenv ENV
    Using base prefix ‘d:\\python3.7-embed’
    Traceback (most recent call last):
    File “”, line 193, in _run_module_as_main
    File “”, line 85, in _run_code
    File “D:\ython3.7-embed\Scripts\virtualenv.exe\”, line 9, in
    File “D:\ython3.7-embed\lib\site-packages\”, line 712, in main
    File “D:\ython3.7-embed\lib\site-packages\”, line 927, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
    File “D:\ython3.7-embed\lib\site-packages\”, line 1149, in install_python
    writefile(site_filename_dst, SITE_PY)
    File “D:\ython3.7-embed\lib\site-packages\”, line 363, in writefile
    with open(dest, ‘wb’) as f:
    FileNotFoundError: [Errno 2] No such file or directory: ‘D:\\projects\\test\\ENV\\\\’
    ———–for virtualenv end


    ———–for venv
    D:\projects\test>python -m venv VENV
    D:\ython3.7-embed\python.exe: No module named venv
    ———–for venv end

  2. Looks like you can also add relative paths, e.g.

    These then show up when calling print(sys.path)

  3. There’s a note in python32._pth:
    # Uncomment to run site.main() automatically
    #import site

    Then `site-packages` folder is added automatically to sys.path

  4. Hey, thanks, everything you mentioned here works for me, but when I try to import a module in the same directory, it fails.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.