Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Install a library manually
#1
NOTICE
This method of installation is not the normal process. The recommended install method is to use pip such as pip install bs4. If you cannot install a module via pip and try this method you are most likely in way over your head and should not be doing it.

You can manually replicated the process of installing a 3rd party library. You should know the underlying of the system and how it works anyways.

We are going to use Python 3.4 for this example. It is installed to the location C:\Python34 in this example. We are going to install the 3rd party libraries beautifulsoup and pygame this method. But you can do this with any 3rd party lib. beautifulsoup does not have any headers, whereas pygame does. 

We show that beautiful soup is not installed on this python
C:\Python34>python.exe
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'bs4'
>>> import BeautifulSoup
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'BeautifulSoup'
We then download the wheel for python 3.4 version
https://pypi.python.org/pypi/beautifulsoup4

rename 
beautifulsoup4-4.5.1-py3-none-any.whl

to the extension of
beautifulsoup4-4.5.1-py3-none-any.zip

then unzip it, and extract it like any other zip file

There will be a bs4 directory and a beautifulsoup4-4.5.1.dist-info directory. Copy these directories over to C:\Python34\Lib\site-packages

before and after directory listing
C:\Python34\Lib\site-packages>dir
 Volume in drive C is Windows
 Volume Serial Number is 3405-69A8

 Directory of C:\Python34\Lib\site-packages

11/05/2016  02:52 AM    <DIR>          .
11/05/2016  02:52 AM    <DIR>          ..
11/05/2016  02:52 AM               126 easy_install.py
11/05/2016  02:52 AM    <DIR>          pip
11/05/2016  02:52 AM    <DIR>          pip-7.1.2.dist-info
11/05/2016  02:52 AM    <DIR>          pkg_resources
05/07/2011  01:04 PM               121 README.txt
11/05/2016  02:52 AM    <DIR>          setuptools
11/05/2016  02:52 AM    <DIR>          setuptools-18.2.dist-info
11/05/2016  02:52 AM    <DIR>          _markerlib
11/05/2016  02:52 AM    <DIR>          __pycache__
               2 File(s)            247 bytes
               9 Dir(s)  787,335,749,632 bytes free

C:\Python34\Lib\site-packages>dir
 Volume in drive C is Windows
 Volume Serial Number is 3405-69A8

 Directory of C:\Python34\Lib\site-packages

11/05/2016  03:02 AM    <DIR>          .
11/05/2016  03:02 AM    <DIR>          ..
11/05/2016  03:02 AM    <DIR>          beautifulsoup4-4.5.1.dist-info
11/05/2016  03:02 AM    <DIR>          bs4
11/05/2016  02:52 AM               126 easy_install.py
11/05/2016  02:52 AM    <DIR>          pip
11/05/2016  02:52 AM    <DIR>          pip-7.1.2.dist-info
11/05/2016  02:52 AM    <DIR>          pkg_resources
05/07/2011  01:04 PM               121 README.txt
11/05/2016  02:52 AM    <DIR>          setuptools
11/05/2016  02:52 AM    <DIR>          setuptools-18.2.dist-info
11/05/2016  02:52 AM    <DIR>          _markerlib
11/05/2016  02:52 AM    <DIR>          __pycache__
               2 File(s)            247 bytes
              11 Dir(s)  787,335,385,088 bytes free
Then open your interpreter and try to import and use beautiful soup as normal. 
C:\Python34>python.exe
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> 
Sometimes you will have to include the header files as well. In this next example we will install pygame which has these

We download the wheel from the unofficial library of 3rd party libs
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

And since our python is version 3.4 and 32 bit we will be downloading the one with py34 (for python3.4) and win23 for (32 bit). What you download depends on your python version and python bit type. 

we change the extension to zip again so windows can detect and extract it.
This time there is a 3rd directory in here. We copy pygame and pygame-1.9.2b1.dist-info to C:\Python34\Lib\site-packages again, just like we did before. Now we need to go back to the extracted directory and go into pygame-1.9.2b1.data directory. There will be a directory named "headers". Rename this directory to "pygame" (all lowercase). Now copy or move this renamed directory to C:\Python34\include directory 

Now go into your python3.4 interpreter and test pygame

C:\Python34>python
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> pygame.init()
(6, 0)
Recommended Tutorials:
Reply


Messages In This Thread
Install a library manually - by metulburr - Nov-04-2016, 07:23 PM
RE: Install a library manually - by Larz60+ - Nov-04-2016, 07:30 PM
RE: Install a library manually - by snippsat - Nov-04-2016, 07:45 PM
RE: Install a library manually - by Larz60+ - Nov-04-2016, 07:58 PM
RE: Install a library manually - by metulburr - Nov-04-2016, 08:31 PM
RE: Install a library manually - by snippsat - Nov-04-2016, 09:11 PM
RE: Install a library manually - by metulburr - Nov-04-2016, 09:55 PM
RE: Install a library manually - by Larz60+ - Nov-04-2016, 10:04 PM
RE: Install a library manually - by metulburr - Nov-06-2016, 04:47 PM
RE: Install a library manually - by Larz60+ - Nov-06-2016, 05:13 PM
RE: Install a library manually - by metulburr - Nov-06-2016, 05:33 PM
RE: Install a library manually - by Larz60+ - Nov-06-2016, 08:33 PM
RE: Install a library manually - by metulburr - Nov-06-2016, 11:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Amazon AWS - how to install the library chatterbot wpaiva 9 3,764 Feb-01-2020, 08:18 AM
Last Post: brighteningeyes
  Python Selenium .click() Loads Error - Works Manually.- Events not Triggered NSearch 24 11,524 Aug-14-2019, 02:23 PM
Last Post: NSearch

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020