Friday, 22 May 2015

Python 3 - Install Modules and Packages Using PIP- Plus Troubleshooting

This is much of a quick reference for me than anything else.

PIP is the installer for modules and packages for Python. You can use it to install modules like mathplotlib and pygame. 
If you want a quick resource for python extension packages for your version of Python and your system then then:

Unofficial Windows Binaries for Python Extension Packages

is your one-stop-shop. 

To Download

Just:
  •  ctrl-f and type the item you want. 
  • Click the link. 
  • Select the version that matches your version of Python and 32 or 64 bit system.
  • Wait for it to down load. 
To Install
Once it has downloaded:
  • Go into your cmd for Windows (bash, iOS, terminal for Linux). In windows. Search for cmd, right click and run as administrator.
  • Once in, type: pip install package
    • For example:

  • Hi enter and it should install. 
  • To test if it works go into your Python terminal and type: import package
    • For example:

  • If there is no error then you have downloaded it successfully. If you get an error it may not have down loaded:


Troubleshooting in the CMD line

There are two issues I have come across that have caused me not to download the image in the command line:

'pip' is not recognized as an internal or external command,
operable program or batch file.

This is usually because you have two versions of pip installed on your computer (and more than likely you have installed Python 2.7 before Python 3.4)

To fix this problem you will need to type the whole path to your version of python you want to install your package on. In my case, I would type something like:

D:/Python34/Scripts/pip install package

Where the package is the name of the package, like mathplotlib. Your path may be in C:/ drive or in a different directory too. 

The second error will run the setup but will come up with:

warning: no files found matching 'distribute_setup.py'

And a big list of syntax errors.

For me, this is either as a result of a spelling mistake on by behalf or PIP could not find the file to install. To fix this I just accessed the directory and file where it was downloaded. 

For example:

pip install C:/Users/Scott/Downloads/package.v2iiBlahBlahBlah.whl

This seems to fix the problem. 



No comments:

Post a Comment