Python Forum

Full Version: Install a library manually
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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)
Isn't this playing with fire?
I don't think I would use this method even if it works.
Especially if the person doing it couldn't do so using standard methods.
This is not the way to do it Dodgy 
Will for sure not work on all modules. 

Destroy much of the point with pip,
which has uninstall and listing of modules.
Version 9.0 also comes with pick check command,
to check the state of installed dependencies.

We should learn beginner to use pip,
and i would say not all the method you use here.
Also pip can be used on downloaded wheels, only need to change to download directory before running.
and run pip install wheelname
I had to do this method to install pygame on windows on somewhere near python3.2 to python3.4. (assuming i did not want to install a compiler) I could not get pip to install pygame for the life of me. 
Quote:Will for sure not work on all modules. 
I have only used it to install pygame on my systems. I had a lot of problems with pip and just wrote it off completely. 

This is based on the fact of one fed up with pip (like me) and wants an alternative.

Besides if people are abandoning python due to either pip problems/unaware of pip usage...is it really that big of a deal to try an alternative method? For bs4 it is a simple copy and paste of 2 directories.
Quote:I had to do this method to install pygame on windows on somewhere near python3.2 to python3.4. (assuming i did not want to install a compiler) I could not get pip to install pygame for the life of me.
In very difficult cases will try a lot other stuff,but pip should be a first advice in all cases.
Quote:This is based on the fact of one fed up with pip (like me) and wants an alternative.
There will not and be an official alternative to pip in Python and that's good,
For many year the Python packaging ecosystem was in a rather confusing and messy state
I think most people in Python community are happy that we now have one clear choice.
Donald Stufft dos really good job with pip.
Quote:Besides if people are abandoning python due to either pip problems/unaware of pip usage...is it really that big of a deal to try an alternative method? For bs4 it is a simple copy and paste of 2 directories.
Juggling between 2 version 2.7 and 3.5 can be confusing when you new to this.

He did not follow exactly what a did advice in my post which would have worked,
think there where a mix-up between version i the way he did choose to do it.
Quote:Isn't this playing with fire?
This is just basically manually doing what pip or setup.py does for you. Except instead of building the library with setup, you are just downloading your systems pre-built via the wheel, and bypassing pip. https://docs.python.org/2/install/#how-i...tion-works

Quote:but pip should be a first advice in all cases.
In the event there is a problem i think alternatives should be documented here.
I myself sometimes would like to skirt the system, and have to admit that (especially with oracle) have done so.
All seems to go well until it doesn't.
I got bit more than once, and always managed to pull myself out of situations that arose
(nothing can ever go wrong go wrong go wrong)


What about updates? and dependencies?
Seems to me there are just too many corner cases that you have to be aware of,
that might cause problems.

some packages haven't been put together properly and don't readily install with pip.
That's a problem of the package, and not pip.
These packages are even more difficult to install without.

I am not trying to be disrespectful. Only devil's advocate. And having managed a staff of
several hundred programmers know the value of standard tools.
I have never had a problem with this method. Though i admit i mostly use a compiler with the setup script to install...never pip on windows or linux. 

I would definitely be interested if a problem arose with this method though.

But i completely understand the need for new users to use pip as (i guess) its now the standard.
Don't forget that the Laboratory for Fluorescence Dynamics at UCLA Irvine
maintains a repository of wheels for python that install with pip.

These are complete installs, and contain all dependencies.

I haven't found one yet that didn't work. You can get them here
Pages: 1 2