为Linux创建便携式Python(本地安装) [英] Creating a Portable Python (local install) for Linux

查看:154
本文介绍了为Linux创建便携式Python(本地安装)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找创建以下内容:

I'm looking to create the following:

可以在任何系统上运行的可移植版本的python(已安装任何以前版本的python或没有python ),并且预先配置了各种python包(即django,lxml,pysqlite等)

A portable version of python that can be run on any system (with any previous version of python or no python installed) and have it pre-configured with various python packages (ie, django, lxml, pysqlite, etc)

我发现上面最接近的是 virtualenv ,但这只能到目前为止。

The closest I've found to the above is virtualenv, but this only goes so far.

如果我打包在一台机器上,很好的virtualenv可用于python,它包含了很多需要的库的sym链接。我可以拿这些sym链接并将它们转换成他们的实际文件,但是如果我尝试把这个整个目录移动到另一个机器上,我会在seg错误之后得到seg错误。

If I package up a nice virtualenv for python on one machine, it contains sym links to a lot of the libraries it needs. I can take those sym links and convert them to their actual files, but if I try to move this entire directory to another machine, I get seg fault after seg fault.

要在不同的机器上启动python,我使用:

To launch python on a different machine, I'm using:

LD_LIBRARY_PATH=lib/ ./bin/python

在lib /我中有我从原始机器复制的所有共享库。这里的问题是这些共享库可能依赖于我不包括的其他共享库,因此在其他linux发行版上执行此操作不起作用。可能是因为它在系统上安装的较旧的共享库中掉下来,而不能与我复制的文件一起使用。

and in lib/ I have all of the shared libraries I copied from the original machine. The problem here is these shared libraries might rely on other shared libraries that I'm not including, so executing this on other linux distros does not work. Probably due to it falling back on older shared libaries installed on the system that do not work with what I copied over.

任何人都有一个想法如何让这个工作?这是可能的吗?

Anyone have an idea on how to get this working? Is this even possible?

编辑:

是创建一个可以在任何基于linux的系统(即ubuntu 8.04,redhat 5,suse 11等)上提取和运行的python二进制和关联包(django,lxml,pysqlite等)的tar.gz,所有32位发行版,其中本地安装的python版本不会影响tar.gz中的内容。

To clarify, the desired outcome is to create a tar.gz of a python binary and associated packages (django, lxml, pysqlite, etc) that can be extracted and run on any linux based system, ie (ubuntu 8.04, redhat 5, suse 11, etc), all 32bit distros, where the locally installed version of python doesn't impact what's in the tar.gz.

推荐答案

我刚刚测试了它的工作原理很好。

I just tested this and it works great.

获取要安装的python的副本,并将其解压缩并首先cd到untarred文件夹。

Get the copy of python you want to install and untar it and cd to the untarred folder first.

还可以获取一个setuptools的副本,然后解压缩。

Also get a copy of setuptools and untar that.

/ opt / portapy 当然这只是我提出的这个帖子的名字,它可以是任何路径,并且完整的路径应该被压缩,并且在由于绝对路径链接而放在上面的任何系统上都应该使用相同的路径。

/opt/portapy used below is of course just the name I came up with for this post, it could be any path and the full path should be tarred up and the same path should be used on any systems you put this on due to absolute path linking.

mkdir /opt/portapy
cd <python source dir>
./configure --prefix=/opt/portapy && make && make install
cd <setuptools source dir>
/opt/portapy/bin/python ./setup.py install

env文件夹在portapy文件夹中。

Make the virtual env folder inside the portapy folder.

mkdir /opt/portapy/virtenv
/opt/portapy/bin/virtualenv /opt/portapy/virtenv
cd /opt/portapy/virtenv
source bin/activate

完成。您可以在这里安装所有的库,并可以选择以这种方式创建多个虚拟envs。

Done. You are ready to install all of your libraries here and have the option of creating multiple virtual envs this way.

然后可以将整个 / opt / portapy 文件夹,并将其传输到同一个arch的任何Linux系统,原因是我怀疑。

You can then tar up the whole /opt/portapy folder and transport it to any Linux system of the same arch, within reason I suspect.

我编译了2.7.5 ond centos 5.8 64bit并将文件夹移动到Cent6.9系统,并且运行完美。

I compiled 2.7.5 ond centOS 5.8 64bit and moved the folder to a Cent6.9 system and it runs perfectly.

这篇关于为Linux创建便携式Python(本地安装)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆