是否有一个命令行标志设置PYTHONHOME? [英] Is there a commandline flag to set PYTHONHOME?

查看:2905
本文介绍了是否有一个命令行标志设置PYTHONHOME?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以一个系统,不允许我设置环境变量上运行的蟒蛇。是否有一个命令行标志,蟒蛇,将设置PYTHONHOME?我看了看这里: http://docs.python.org/release /2.3.5/inst/search-path.html 但什么也没看见。

I'm attempting to run python on a system that doesn't allow me to set environment variables. Is there a commandline flag to python that will set PYTHONHOME? I looked here: http://docs.python.org/release/2.3.5/inst/search-path.html but didn't see anything.

所以,我希望这样的事情:

So, hopefully something like this:

python -magical_path_flag /my/python/install test.py

修改

感谢您的答复大家。我不好意思地说,我实际上意味着PYTHONHOME,不PYTHONPATH。 (这是我应得问一个问题,在上午01:30)。我已经编辑我的quesiton。

Thanks for the responses everyone. I'm embarrassed to say I actually meant PYTHONHOME, not PYTHONPATH. (That's what I deserve for asking a question at 1:30 AM.) I've edited my quesiton.

下面的一些信息。我试图让Python运行在Android上。我可以运行Python -V没有问题,但如果我尝试和执行一个脚本,我得到:

Here's some more info. I'm trying to get python running on Android. I can run python -V no problem, but if I try and execute a script, I get:

I/ControlActivity(18340): Could not find platform independent libraries <prefix>
I/ControlActivity(18340): Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

使用的ProcessBuilder和改变在Android环境变量

不幸的是,当,它说,他们没有修改,并抛出一个异常。我能够通过所有我想要的命令行标志,所以我希望我可以设置PYTHONHOME的方式。

Unfortunately when using the ProcessBuilder and changing the environment variables on Android, it says that they're not modifiable and throws an exception. I'm able to pass all the command line flags I want, so I was hoping I could set PYTHONHOME that way.

我试图创造一个包裹shell脚本出口PYTHONHOME,然后调用蟒蛇,但没有奏效。 (和以前一样得到了同样的错误。)

I've tried creating a wrapping shell script which exports PYTHONHOME and then calls python but that didn't work. (Got the same error as before.)

谢谢

加布

推荐答案

您可以简单地设定在脚本 - 的sys.path 是有规律的,修改列表。是这样的:

You could simply set it in your script -- sys.path is a regular, modifiable list. Something like:

import sys
sys.path.append("/path/to/libraries")

应该做的伎俩

should do the trick

这篇关于是否有一个命令行标志设置PYTHONHOME?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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