?
Solved

How to install python packages nympy and pylab on linux without root permissions?

Posted on 2011-10-14
16
Medium Priority
?
643 Views
Last Modified: 2012-08-14
I am a Python newbie, who need to prepare the python framework to run a python program on a linux machine on which I don't have root permissions. The program is known to work on python 2.6. The system python version in /user/bin/python is older (2.4).

So I have downloaded and built python 2.6 from source and installed it in /home/web/tools/ where I have permissions:
configure --prefix=/home/web/tools; make; make install

Now, the problem is that the python program depends on (imports) the numpy and pylab packages (and whatever they may depend on as well). How to do this in a clean and standard way without root permissions?
0
Comment
Question by:Phazz
  • 6
  • 5
  • 5
16 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 36967919
For all the standard installs, you definitely need root permissions either doing su - or sudo su - .

What kind of Linux is it?  RedHat/CentOS/SL or Ubuntu/Debian etc?

You will have to first install the missing packages and install python.
0
 

Author Comment

by:Phazz
ID: 36968253
Scientific Linux SL release 5.4, it is a Linux distribution based on Red Hat Enterprise Linux.

OK, first step is to install python 2.6.7 (like shown above). It gives some crypic error messages, but it is actually installed and I can start it. Can I ignore the error messages ?

** WARNING: renaming "readline" since importing it failed: /usr/lib64/libreadline.so.5: undefined symbol: PC

Failed to find the necessary bits to build these modules:
_bsddb             _curses            _curses_panel  
_hashlib           _sqlite3           _ssl            
_tkinter           bsddb185           bz2            
dbm                dl                 gdbm            
imageop            sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


Failed to build these modules:
readline    
0
 
LVL 17

Assisted Solution

by:gelonida
gelonida earned 800 total points
ID: 36968268
'Simplest' is to download all packages, that you need and build then from the sources and install them in your python environment.

The manual way to download and compile a python package is:
search the package (most of them can be found on http://pypi.python.org )
and download it.

unpack it and
run
/home/web/tools/bin/python setup.py install


Some tools, like easy_install and pip help you to download and install, so I would download
easy_install and pip first and install them within your python2.6. release.


I would use pip whenever possible:
Pip should try to download (if necessary compile) and install a package.

So install first pip from http://pypi.python.org/pypi/pip
The download link should be  http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz

Untar it and call
/home/web/tools/bin/python setup.py install

now you should be able to install other packages with it
/home/web/tools/bin/pip install numpy


Some of these packages need compilation and require the header files of certain libraries.
Ideally you should be able to convince the administrator to install all these source packages.

Normally you should be able to deduct, which packages you have to install on your linux distribution.

On Ubuntu I would for example install
build-essential
python-dev
libxml2-dev

If the compilation complains about issues with libxml2, you have to install the related packages
which would be under Ubuntu  libxml2 and  libxml2-dev

If you cannot ask root to install source packages for you, then you had to install all the required libraries before being able to compile.

For each of the packages you had to specify a prefix during the build phase, and you had to be sure, that the libraries can be found via PATH / LD_LIBRARY_PATH before running your python compile scripts.






0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:farzanj
ID: 36968398
Did you try:

yum upgrade python
0
 

Author Comment

by:Phazz
ID: 36968568
I tired it now:

yum upgrade python
Loaded plugins: kernel-module
You need to be root to perform this command.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 36968612
Of course, you will need to be root no matter how you try to install.  In Linux, it a very bad idea trying to install as a common user.  If you don't own the machine, you may not even have good enough space to do so and I don't think the System Admin would appreciate you loading binaries on a user account.
0
 
LVL 17

Expert Comment

by:gelonida
ID: 36968640
Farzanji.

You don't have to be root to install python and all packages.
However it is much more work than not being root.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 36968729
gelonida,

Theoretically you don't.  But it is an extremely bad practice to install in an unusual location.  There are situations when you are building RPM packages and testing installs and you don't want to corrupt that machine, you do things like this but I would never recommend something that could potentially put someone in trouble with the admin.  I have managed 3,000-10,000 servers in multiple companies and policies about installs are typically similar.  No admin would like this to happen in his machine.I
0
 

Author Comment

by:Phazz
ID: 36968816
You're right. And it's far more complex than I imagined anyway.

The simplest would probably be if I could get the python script to work with the system python version (2.4). Now, excuse me if the following is a stupid question. What about the packages the script is importing (numpy, pylab); can they be in located in user space, or must I convince the Adm to install them in system space?
0
 
LVL 17

Expert Comment

by:gelonida
ID: 36968857
farzanj.

Depending on the company you are working for, the company policies  and the goodwill /
lazyiness of the admin some bizarre setups show up.

What I agree though  is, that you should ask the admins what they prefers.

- Installing the entire python for you (with all modules like numpy)

- Install
    - basic python, virtualenv and loads of source modules
    - let you compile pyton packages in your virtualenv

- let you install everything by yourself in non custom paths
0
 
LVL 17

Expert Comment

by:gelonida
ID: 36968871
Python 2.4 is really old.

You will have loads of trouble finding all the packages.

From python 2.5 on things are already much better.

Couldn't you get a virtual machine installed for you (where you have root privileges???)
or run everything on a Windows PC? (where you have privileges to install software)
0
 
LVL 31

Accepted Solution

by:
farzanj earned 1200 total points
ID: 36968921
@Phazz:

No question is stupid.  IMHO, you should contact the admin and tell them what you need.  At least you would have no fear in your mind.  He may even have quotas set up.

On Redhat family, the best practice is to install through RPMS.  Improper installs are also against policy due to security vulnerabilities.  To answer you question, you should not put even packages on your account.

@gelonida,  It is an open forum and you may be a lot more experience than I have, but I have some ideas too.  I have no problem with Phazz accepting your solution.  I just want to say what I think is the best practice.
0
 

Author Comment

by:Phazz
ID: 36969027
Thanks for your help so far, I'll talk to admin next week .... have a nice weekend!
0
 
LVL 17

Expert Comment

by:gelonida
ID: 36969393
@farzanj I apologize if I seemed rude in any way. You provided many valid contributions to this thread and in no way did I intend to imply that you don't have any ideas.

I focused more on what's technically possible (virtualenv, etc) you focused more on whether it is really a smart idea to do what I suggested.
Further you gave information about Redhat, which I used last many years ago.

All this are important considerations.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 36969443
@gelonida: Thanks for a nice gesture.  I am really getting rusty on my Python (used until 2000), maybe I can use your help there.

Have a wonderful weekend!
0
 

Author Closing Comment

by:Phazz
ID: 37016851
Eventually I managed to get the python program running with the system python in /user/bin/python (2.4).

I'm accepting both of your solutions, although I tend to agree the most with farzanj; things stay simple if I don't start messing with non-system python installations. On the other hand, I guess it could have been necessary in the rare case of a really lazy and grumpy admin ;)

I have the impression that python version compatibility is problematic?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question