2

I have to deploy a python application to a production server (Ubuntu) that I do not control nor do I have permissions to apt-get, pip, virtualenv, etc. Currently, its the server is running python 2.6+. I need to install pycrypto as a dependency for the application but given my limited permissions, I'm not sure as to how to do it. The only think I have permissions to do is wget a resource and unpack it or things along those lines.

First off, is it possible to use it without getting it installed in the aforementioned approach? If not, could I download the package then drop in __init__.py files in the pycrypto dir so python knows how to find it like so:

/my_app /pycrypto /__init__.py /pycrypto.py 
1
  • you could try putting it in your PYTHONPATH . Commented Jun 17, 2014 at 15:23

2 Answers 2

4

According to PEP370, starting with python 2.6 you can have a per-user site directory (see the What's new in Python 2.6?).

So you can use the --user option of easy_install to install the directory for each user instead of system-wide. I believe a similar option exists for pip too. This doesn't require any privileges since it only uses current user directories.

If you don't have any installer installed you can manually unpack the package into:

~/.local/lib/python2.6/site-packages 

Or, if you are on Windows, into:

%APPDATA%/Python/Python26/site-packages 

In the case of pycrypto, the package requires building before installation because it contains some C code. The sources should contain a setup.py file. You have to build the library running

python setup.py build 

Afterwards you can install it in the user directory by giving:

python setup.py install --user 

Note that the building phase might require some C library to already be installed.


If you don't want to do this, the only option is to ship the library together with your application.


By the way: I believe easy_install doesn't really check whether you are root before performing a system wide install. It simply checks whether it can write in the system-wide site directory. So, if you do have the privileges to write there, there's no need to use sudo in the first place. However this would be really odd...

Sign up to request clarification or add additional context in comments.

12 Comments

Looks like I don't have easy_install either which sucks. So to be clear, when you say shipping the library with my app, you mean in a manner that I listed in the question or another way?
@Brad I just updated my answer. You just have to copy the package in the per-user site directory. See my answer and the linked documentation for in-depth details. Some complex installations would require to modify some .pth found, but that is generally easy. If the basic copy/paste doesn't work leave me a comment and I'll check whether pycrypto requires a bit of configuration.
Of course easy_install does check permissions neither does pip but ubuntu certainly does check.
@PadraicCunningham I don't see the point of your comment. I simply wanted to clarify that: system install does not imply required use of sudo. You can be able to perform a system install without sudo privileges (although that's quite an odd thing to do...)
I don't get what you mean, if you want to install python packages on ubuntu using pip or easy_install to the default packages directory you need sudo. Basically being able to install system-wide without sudo defeats the purpose of having sudo in the first place.
|
0

Use easy_install. It should be installed already on Ubuntu for python 2.6+. If not take a look at these install instructions.

4 Comments

how would you install without sudo?
@PadraicCunningham is easy_install not on the system already?
you need sudo to install packages in any /usr subdirectories where I imagine python is installed.
@PadraicCunningham Not if you install just for your user.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.