带有所有 Python 库的 virtualenv [英] virtualenv with all Python libraries

查看:22
本文介绍了带有所有 Python 库的 virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取 Python 代码,它依赖于 Python 2.6,在只有 Python 2.3 的机器上运行(我没有 root 访问权限).

I need to get Python code, which relies on Python 2.6, running on a machine with only Python 2.3 (I have no root access).

这是 virtualenv 的典型场景.唯一的问题是我无法说服它也将所有库复制到新环境中.

This is a typical scenario for virtualenv. The only problem is that I cannot convince it to copy all libraries to the new environment as well.

virtualenv --no-site-packages my_py26 

不做我需要的.库文件仍然只是指向 /usr/lib/python2.6 目录的链接.

does not do what I need. The library files are still only links to the /usr/lib/python2.6 directory.

不,我想知道 virtualenv 是否完全适合这种情况.据我了解,它仅针对在具有完全相同 Python 版本的机器上运行.像 cx_Freeze 之类的工具对我不起作用,因为我在一些环境变量 tweeking 之后启动了 Python 文件.

No I'm wondering, whether virtualenv is the right solution for this scenario at all. From what I understand it is only targetted to run on machines with exactly the same Python version. Tools like cx_Freeze and the like do not work for me, as I start the Python file after some environment variable tweeking.

是否有隐藏的 virtualenv 选项可以将所有 Python 库文件复制到新环境中?或者其他一些可以提供帮助的工具?

Is there maybe a hidden virtualenv option that copies all the Python library files into the new environment? Or some other tool that can help here?

推荐答案

我无法帮助您解决您的 virtualenv 问题,因为我从未使用过它.但我会指出一些东西以备将来使用.

I can't help you with your virtualenv problem as I have never used it. But I will just point something out for future use.

您可以将源中的软件安装到您的主文件夹中,并在没有 root 访问权限的情况下运行它们.例如安装python 2.6:

You can install software from sources into your home folder and run them without root access. for example to install python 2.6:

~/src/Python-2.6.2 $ ./configure --prefix=$HOME/local
~/src/Python-2.6.2 $ make
 ...
~/src/Python-2.6.2 $ make install
 ...
export PATH=$HOME/local/bin:$PATH
export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH

~/src/Python-2.6.2 $ which python
/home/name/local/bin/python

这是我在 Uni 用来安装我没有 root 访问权限的软件的方法.

This is what I have used at Uni to install software where I don't have root access.

这篇关于带有所有 Python 库的 virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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