How can I use numpy without installing it?

后端 未结 4 993
醉梦人生
醉梦人生 2021-01-04 20:22

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 --u

相关标签:
4条回答
  • 2021-01-04 21:06

    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.

    0 讨论(0)
  • 2021-01-04 21:13

    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

    0 讨论(0)
  • 2021-01-04 21:13

    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.

    0 讨论(0)
  • 2021-01-04 21:19

    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)

    0 讨论(0)
提交回复
热议问题