Monday, 12 November 2018

Using pip on Windows

This is a slightly self-centred post, as I am doing it primarily for my own reference. As I previously mentioned, pip is the program that allows Python coders to download and install third-party modules. So if you hear about a useful module that doesn't come bundled with Python, you use pip to get it to work.
Okay, this is what's worked for me on my Windows 10 machine.

Open up Windows command line (not IDLE).
CD to where your Python is installed. For me this is
C:\Users\666\AppData\Local\Programs\Python\Python36-32
Then use the command
python -m pip install modulename

for example upgrading the pip module:
C:\Users\666\AppData\Local\Programs\Python\Python36-32>python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 3.3MB/s
Installing collected packages: pip
  Found existing installation: pip 18.0
    Uninstalling pip-18.0:
      Successfully uninstalled pip-18.0
Successfully installed pip-18.1

C:\Users\666\AppData\Local\Programs\Python\Python36-32>python -m pip install PIL

and again:

C:\Users\666\AppData\Local\Programs\Python\Python36-32>python -m pip install Image
Collecting Image
  Downloading https://files.pythonhosted.org/packages/0c/ec/51969468a8b87f631cc0e60a6bf1e5f6eec8ef3fd2ee45dc760d5a93b82a/image-1.5.27-py2.py3-none-any.whl
Collecting pillow (from Image)
  Downloading https://files.pythonhosted.org/packages/6c/60/4c0e6702a39eab8d5d4d210f283907cbe387fcffeb873d8eb8c3757a21a9/Pillow-5.3.0-cp36-cp36m-win32.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 2.1MB/s
Collecting django (from Image)
  Downloading https://files.pythonhosted.org/packages/32/ab/22530cc1b2114e6067eece94a333d6c749fa1c56a009f0721e51c181ea53/Django-2.1.2-py3-none-any.whl (7.3MB)
    100% |████████████████████████████████| 7.3MB 2.1MB/s
Collecting pytz (from django->Image)
  Downloading https://files.pythonhosted.org/packages/52/8b/876c5745f617630be90cfb8fafe363c6d7204b176dc707d1805d1e9a0a35/pytz-2018.6-py2.py3-none-any.whl (507kB)
    100% |████████████████████████████████| 512kB 536kB/s
Installing collected packages: pillow, pytz, django, Image
  The script django-admin.exe is installed in 'C:\Users\666\AppData\Local\Programs\Python\Python36-32\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed Image-1.5.27 django-2.1.2 pillow-5.3.0 pytz-2018.6

Note that all of this is on the Windows command line, not IDLE. 
I wanted to install the Image module as I wanted to something with images. Pip (or at least the system it talks to) then decided that it was necessary to download and install other modules. One of the things about modules is that they may have dependencies - some require other modules to function. 

No comments:

Post a Comment