9

I console access to a computer where I do not have root nor sudo rights.

Python version is 2.5.2 and numpy is not available. I cannot use python setup.py install --user nor there are any compilers available on the machine.

Can I somehow use the compiled packages available https://edge.launchpad.net/~scipy/+archive/ppa/+packages without installing them? I tried importing the numpy module directly but it complains:

Python 2.5.2 (r252:60911, Jan  4 2009, 21:59:32)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/home/XXX/temp/python-numpy-1.2.1/numpy/__init__.py", line 121,
 in <module>
    raise ImportError(msg)
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python intepreter from there.
>>>

Thanks!

Update: The sysadmin will not install any kind of software in the machine (it's a VPS and my guess is that they have a standard image for deployment). They are crazy paranoic, they won't even tell me what flavor of unix they are running, and even the Apache service has the version number obfuscated! This is all the information I get upon login:

Linux server1 2.4.22 #4 SMP Wed Nov 5 17:44:16 CET 2003 i686 unknown

And for compiling:

python setup.py install --home=~
[...]
RuntimeError: Broken toolchain: cannot link a simple C program

cat /proc/version

Linux version 2.6.32.25-grsec-dh (root@dl345.dinaserver.com) (gcc version 4.3.2
(Debian 4.3.2-1.1) ) #2 SMP Wed Nov 3 13:21:01 CET 2010
Josep Valls
  • 5,483
  • 2
  • 33
  • 67
  • 2
    the same way you can use windows without installing it. –  Aug 08 '11 at 00:41
  • @Franklin: You can (kinda)!! See BartPE. – Chinmay Kanchi Aug 08 '11 at 07:35
  • 1
    You might find out the distribution information using `cat /etc/*-release` ;) – plaes Aug 08 '11 at 07:53
  • Also, if that doesn't work `cat /proc/version` might give you a hint. – Chinmay Kanchi Aug 08 '11 at 09:06
  • Time to get a new VPS provider then :). Unless they've changed something to report a misleading version, 2.4.22 is _ancient_ (released in Aug. 2003) and missing several security fixes. For example, there appears to be a fix in 2.4.27 to prevent users from changing the GID for arbitrary files. So, for all their paranoia, they're leaving their kernel unpatched, which is a Bad Thing (TM). There are plenty of excellent managed and unmanaged VPS providers out there, many of whom are very reasonably priced. – Chinmay Kanchi Aug 08 '11 at 09:26
  • Probably you are right, new VPS will be :) Now that I got the system information will try to replicate. The VPS is a spare system used by my company (and already paid for the year) and was trying to give it some use. Just as a warning for Spain-based folks: Avoid Dinahosting.com at all costs! – Josep Valls Aug 08 '11 at 11:18
  • So yes, they are fuzzing the kernel version in the login message. But a VPS you can't do anything with is kind of pointless :). If you want something _really_ barebones and unmanaged (and insanely cheap!), try the ones at www.lowendbox.com. Otherwise, there are plenty of _excellent_ managed VPS services. Try the forums at webhostingtalk.com. – Chinmay Kanchi Aug 08 '11 at 15:27

5 Answers5

5

If you can resolve all the dependencies, you might be able to install it in your $HOME using dpkg. dpkg doesn't resolve dependencies automatically, so you might have to figure out the right order to install the packages in. Download the .deb files that you're interested in and run the following command for each package:

$ dpkg -i --force-not-root --root=$HOME mypackagename.deb

If you then add the directory with the newly installed Numpy to your $PYTHONPATH, or to sys.path, Numpy might just work.

Alternatively, you might be able to extract the files you need from one of the other binary distributions of Numpy around (such as Sage).

Numpy is quite fussy about what versions of its dependencies it requires though, so you're probably best off downloading the packages for the specific version of Linux that you're using.

Finally, consider asking your administrator whether s/he'll install Numpy for you. You'd be surprised how often a simple request can solve all your problems, especially since it's just one apt-get command.

EDIT: Just as an alternative, if you can get access to another machine running the same version/architecture of Ubuntu/Debian, you might be able to download the numpy source tarball, compile with python setup.py build and then just copy everything in directory_where_you_extracted_the_tarball/build/numpy/lib.OS-arch-PythonVersion (on my system, it is lib.linux-x86_64-2.6/) to a directory of your choice on the target machine. Then, just add that directory to your $PYTHONPATH and you're done. Remember to copy the contents, not the whole directory (tar -jcf np.tar.bz2 /path/to/numpy/build/numpy/lib.OS-arch-PythonVersion/numpy then get the tar.bz2 to the remote machine and extract it in a directory of your choice).

There is some documentation on how to use setuptools here: http://docs.python.org/install/index.html#how-installation-works

Building Numpy by hand is not for the faint of heart though, so this might lead to a lot of head-banging and hair-tearing.

Chinmay Kanchi
  • 62,729
  • 22
  • 87
  • 114
  • I tried your first suggestion, but the user I have access to is really limited. I can't run dpkg. Your second alternative makes a lot of sense, will try it. The last option was what I had in mind but the fact that I don't even know what flavor of Linux the machine is running will make it rough. I don't even have access to uname! – Josep Valls Aug 08 '11 at 07:12
  • If your machine is *that* locked down, are you even sure that the administrator will like user-installed libraries? I don't know what the specifics of your situation are, but doing this on a machine this locked down without at least asking the admin seems like a good way to get kicked off :). – Chinmay Kanchi Aug 08 '11 at 07:26
  • Also, do you know that the system is Debian-based? Since you tried a PPA, I assumed it was a Ubuntu-ish system. If not, perhaps you're barking up the wrong tree with Debian/Ubuntu packages. – Chinmay Kanchi Aug 08 '11 at 07:33
3

I'm not 100% this will work, but Enthought has a free version of the EPD that has numpy and scipy included, that may not require a compiler to install (since it's just installing binaries as far as I can tell), and doesn't need root access:

http://www.enthought.com/products/epd_free.php

JoshAdel
  • 66,734
  • 27
  • 141
  • 140
1

You could try setting up a virtualenv environment on a similar machine with similar architecture. Then install virtualenv locally on the VPS machine and try copying the environment there.

plaes
  • 31,788
  • 11
  • 91
  • 89
0

You can use python's distutils (which is what python setup.py runs) install to a local directory, which must be added to your PYTHONPATH. E.G.,

python setup.py install --prefix=~/local

which uses a directory hierarchy ~/local/lib/python2.x. (Or you can use --home=<dir> to avoid the python2.x part)

Andrew Jaffe
  • 26,554
  • 4
  • 50
  • 59
  • Where do I download a compiled version to install? I had already tried but I got the error message: RuntimeError: Broken toolchain: cannot link a simple C program – Josep Valls Aug 08 '11 at 07:19
  • 1
    As the OP said, no compilers. Numpy has no official binary distributions for Linux, so if you can't somehow source precompiled binaries, you're SOL. – Chinmay Kanchi Aug 08 '11 at 07:29
0

Unlike the setup.py or pip-based methods, installing Numpy via conda does not require having access to any compilers.

  1. Install some form of conda. I'll suggest using mambaforge:

    curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh"
    bash Mambaforge-$(uname)-$(uname -m).sh
    
  2. Use conda/mamba/micromamba to install Numpy from the conda-forge channel into a new conda environment named my_env:

    mamba create -n my_env -c conda-forge numpy
    
  3. Activate the conda environment:

    mamba activate -n my_env
    
  4. Run python with numpy installed:

    python
    
Will Holtz
  • 677
  • 5
  • 17