How to install python from source without internet connection? - python

I'm installing python on custom location on a internal server.
Unfortunately, I can't make full internet connection here. Most of sites are block by firewall. (essentially pypi repository!) Please don't ask the reason. And I don't have root account, so I have to install python from source.
I did install python from source successfully! But the problem is any of easy_install or pip is not installable because the sites are not accessible form here. :(
How can I install them under current situation?

Download the source tarballs of the module you are interested in to your PC
Upload it to the remote server (SCP)
Extract the tarball (eg. tar -xvzf pack.tar.gz)
Set the current directory to the extracted folder (should contain a file named setup.py)
Install the module: python setup.py install (See documentation)
In my eyes setting up a local mirror like proposed by Tim is not worth of it (Of course this depends on how often you plan to install/update Python modules on that remote machine...)

Download the source tarballs of the relevant modules and install them locally.

easy_install /your/file/location/pack.tar.gz

Related

How to make a private module pip installable?

I have python package which need to be installed to run a Django project?
I go into the python virtual environment and clone the module from git in site-packages folder inside lib.
What i need is to make that module pip intallable and installation access should be given only to specific people i.e that module should not be public to everyone.
Build the python package as you normally would for a public build. For helpful step-by-step instructions on that front, check out the python docs
There are a number of ways to maintain both installability and privacy. When I looked into this for my own packages I started with the suggestions at this site. This site includes instructions on how to build your own equivalent of a PyPi server.
The solution I landed on though, I feel is quite simpler. I pushed the entire package to a private git repository hosted on github. You can then install using pip install git+[insert full url to your github repository here]. You can enforce privacy by restricting who has access to your git repository.
To make your package part of the requirements, place it where it will be accessible only by the people you want to have access, e.g. on a private github. Then you can add a line like this to any project's requirements.txt, and pip will fetch it and install it:
-e git://github.com/<user>/<package>.git#egg=<package>
(Replace with the name of the package you are distributing.) This line is simply added to the list of simple package names that requirements.txt usually contains. You could also replace the git download with an egg placed on a local fileshare, or whatever.

Offline Installation of python & pip

I need to install python on a sever to run scripts but the server has no access to the internet.
The server has access to a local network that has access to the internet*. I would like to use pip to manage the packages through a local network directory as specified here.
How can I install pip, python and their dependancies on a windows machine, offline so that I can use pip, as specified in the link above to manage the packages I require?
*For Clarity: I have no ability to mirror, hack or otherwise to get information to pass through the local network directly from the internet.
The official Python installer for Windows has no other dependencies. It runs completely offline.
For other packages that may have dependencies (that are difficult to install on Windows); Christopher Gholke maintains a list of Windows installers for common Python packages. These are msi installers (or whl files) that are self-contained.
They are designed to work with the official Python installer for Windows - as they use its registry entries to identify the install location.
You can download these and move them to your Windows machine.
Beyond those two - if you have further requirements you can use tools like basket to download packages and then provide the location as a source for offline pip installs; or create your own pip repository.
If you do decide to create a local pip repository, it is better to create a pip proxy (see pypicache for example) this way you are only requesting those packages that are required, rather than trying to mirror the entire cheeseshop.

How to manually install Google Data Python library?

I don't know how to install Google Data Python library, and I'm not a programmer either. I don't understand the Google Developers guide and on YouTube, the guy doesn't show how he install it (scripts maybe) on the python.
I tried Getting Started with the Google Data Python Library, but I'm only at step 2.
I'm stuck at "Installing the Google Data Library":
Download the Google Data Python library if you haven't done so. Look for the latest version on the Python project's downloads page.
After downloading the library, unpack it using unzip or tar zxvf depending on the type of download you chose.
Now you are ready to install the library modules, so that they can be imported into Python. There are several ways you can do this:
If you have the ability to install packages for all users to access, you can run ./setup.py install from the unpacked archive's main directory.
If you want to install these modules for use in your home directory, you can run ./setup.py install --home=<your home directory>
If you're using a Mac, download the Google Data Python library, then double click the file in your Downloads directory, which will automatically unpack it, regardless of whether you downloaded the .zip or .tar.gz version of the file.
Next, open Terminal, cd to the directory where the library has been installed (e.g.: cd ~/Downloads/gdata-2.0.18), and try running the commands they mention.
If the second paragraph doesn't make any sense to you, go here: http://cli.learncodethehardway.org/book/ and all will become clear. Don't worry, it's not book-length.

Install github clones of a python package to WinPython

I'm trying to install a package, pybrain, from its github website. It does not have nicely packaged archive files or executables, so I don't know how to install it via WPPM.
Do I still do python setup.py install, or do I copy the pybrain folder manually to the site-packages? I figured one thing I can do is to
python setup.py sdist
to generate an archive file, and then use WPPM to do it. Is this the "best" way?
Thanks in advance!
PS: Sorry that I don't have enough reputation to initiate the tag of "WinPython".
Most packages that are configured properly with distutils will automatically place themselves in the correct location with "python setup.py install"
Having had similar issues, especially sitting behind a corporate firewall, I found the easiest way to install things from github repositories is to download the repository as a zip file, then use the WPPM to add the package from there. Github repositories give the option of downloading as a zip on the right hand side. I've found that the package manager handles everything correctly from there.

Best practice for installing python modules from an arbitrary VCS repository

I'm newish to the python ecosystem, and have a question about module editing.
I use a bunch of third-party modules, distributed on PyPi. Coming from a C and Java background, I love the ease of easy_install <whatever>. This is a new, wonderful world, but the model breaks down when I want to edit the newly installed module for two reasons:
The egg files may be stored in a folder or archive somewhere crazy on the file system.
Using an egg seems to preclude using the version control system of the originating project, just as using a debian package precludes development from an originating VCS repository.
What is the best practice for installing modules from an arbitrary VCS repository? I want to be able to continue to import foomodule in other scripts. And if I modify the module's source code, will I need to perform any additional commands?
Pip lets you install files gives a URL to the Subversion, git, Mercurial or bzr repository.
pip install -e svn+http://path_to_some_svn/repo#egg=package_name
Example:
pip install -e hg+https://rwilcox#bitbucket.org/ianb/cmdutils#egg=cmdutils
If I wanted to download the latest version of cmdutils. (Random package I decided to pull).
I installed this into a virtualenv (using the -E parameter), and pip installed cmdutls into a src folder at the top level of my virtualenv folder.
pip install -E thisIsATest -e hg+https://rwilcox#bitbucket.org/ianb/cmdutils#egg=cmdutils
$ ls thisIsATest/src
cmdutils
Are you wanting to do development but have the developed version be handled as an egg by the system (for instance to get entry-points)? If so then you should check out the source and use Development Mode by doing:
python setup.py develop
If the project happens to not be a setuptools based project, which is required for the above, a quick work-around is this command:
python -c "import setuptools; execfile('setup.py')" develop
Almost everything you ever wanted to know about setuptools (the basis of easy_install) is available from the the setuptools docs. Also there are docs for easy_install.
Development mode adds the project to your import path in the same way that easy_install does. An changes you make will be available to your apps the next time they import the module.
As others mentioned, you can also directly use version control URLs if you just want to get the latest version as it is now without the ability to edit, but that will only take a snapshot, and indeed creates a normal egg as part of the process. I know for sure it does Subversion and I thought it did others but I can't find the docs on that.
You can use the PYTHONPATH environment variable or symlink your code to somewhere in site-packages.
Packages installed by easy_install tend to come from snapshots of the developer's version control, generally made when the developer releases an official version. You're therefore going to have to choose between convenient automatic downloads via easy_install and up-to-the-minute code updates via version control. If you pick the latter, you can build and install most packages seen in the python package index directly from a version control checkout by running python setup.py install.
If you don't like the default installation directory, you can install to a custom location instead, and export a PYTHONPATH environment variable whose value is the path of the installed package's parent folder.

Categories