从USB驱动器运行python [英] Running python from a usb drive

查看:63
本文介绍了从USB驱动器运行python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿:


我试图从windows xp下的usb驱动器运行python。我为这个用户安装了b $ b $ python。在一台机器上,然后将整个Python24目录复制到usb驱动器上。


我在驱动器根目录下的批处理文件中有以下内容:


@ path =%PATH%;%CD%Python24;%CD%Python24 \libs;%CD%Py thon24 \Scripts;%CD%Python24 \Lib \\ \\ _site-packages;%CD%Python24 \ DLLs

@set pythonpath =%CD%Python24

@ cmd


当我双击文件并在提示符下键入''python''我在一个

工作的python环境中,我能够在

站点中导入模块-packages目录(在本例中为django)。


然而,当我直接从cmd提示符运行脚本时(在这种情况下

''django -admin.py''脚本运行,但无法从

site-packages目录导入模块。


是否有python的命令行选项.exe或环境变量

我可以设置解决这个问题吗?


你还有别的吗? ghts?


提前致谢,

CJL

解决方案

< blockquote>如果制作一个usb版本的python是那么简单,可移动的python将是b / b
是开源的。查看 http://www.voidspace.org.uk/python/movpy / 如果

你需要一个便携式usb版本的python用于工作或其他东西。

复制Python24目录是一个好的开始,但不包括

安装中包含的大量注册表项和/或
可能需要完整的python功能。我真的很好

希望我不会错过了解你所询问的内容-_-;

环境变量?尝试设置用户/系统变量

" pythonpath"

cjl写道:


嘿:


我试图从windows xp下的usb驱动器运行python。我为这个用户安装了b $ b $ python。在一台机器上,然后将整个Python24目录复制到usb驱动器上。


我在驱动器根目录下的批处理文件中有以下内容:


@ path =%PATH%;%CD%Python24;%CD%Python24 \libs;%CD%Py thon24 \Scripts;%CD%Python24 \Lib \\ \\ _site-packages;%CD%Python24 \ DLLs

@set pythonpath =%CD%Python24

@ cmd


当我双击文件并在提示符下键入''python''我在一个

工作的python环境中,我能够在

站点中导入模块-packages目录(在本例中为django)。


然而,当我直接从cmd提示符运行脚本时(在这种情况下

''django -admin.py''脚本运行,但无法从

site-packages目录导入模块。


是否有python的命令行选项.exe或环境变量

我可以设置解决这个问题吗?


还有其他想法吗?


提前致谢,

CJL


Jordan:


感谢您的回复。


如果制作一个usb版本的python就是这么简单,可移动的python会

是开源的。



我知道可移动的python,但我没有使用它,因为它没有打开

source。我想那些家伙,但有些人会参与其中,感觉像是一个小的b / b $ b费用是合适的,但我想我宁愿使用一些开放的东西,即使是

如果这意味着我必须自己制作。


复制Python24目录是一个好的开始,但不包括

庞大的注册表数量安装中包含的密钥和

可能是python的完整功能所必需的。



Windows python安装程序的源代码是否可用?我想我可以看看他们设置的注册表项是什么......


环境变量?尝试设置用户/系统变量pythonpath



我设置了pythonpath,见上文。


还有其他想法吗?


再次感谢,

CJL


cjl schrieb:


>


我设置pythonpath,见上文。



pythonpath是否真的不区分Windows?


Hey:

I am trying to run python from a usb drive under windows xp. I
installed python "for this user" on to a machine, then copied the
entire Python24 directory to the usb drive.

I have the following in a batch file at the root of the drive:

@path=%PATH%;%CD%Python24;%CD%Python24\libs;%CD%Py thon24\Scripts;%CD%Python24\Lib\site-packages;%CD%Python24\DLLs
@set pythonpath = %CD%Python24
@cmd

When I double click the file and type ''python'' at the prompt I am in a
working python environment, and I am able to import modules in the
site-packages directory (in this case, django).

However, when I run a script directly from the cmd prompt (in this case
''django-admin.py'' the script runs, but fails to import modules from the
site-packages directory.

Is there a command line option to python.exe or an environment variable
I can set to remedy this?

Any other thoughts?

Thanks in advance,
CJL

解决方案

If making a usb version of python was that easy, movable python would
be open source. Check out http://www.voidspace.org.uk/python/movpy/ if
you need a portable usb version of python for work or something.
Copying the Python24 directory is a good start, but doesn''t include the
enormous number of registry keys that are included in the install and
are probably needed for the complete capabilites of python. I really
hope I didn''t missunderstand what you were asking about -_-;
Environmental Variables? Try setting the user/system variable
"pythonpath"
cjl wrote:

Hey:

I am trying to run python from a usb drive under windows xp. I
installed python "for this user" on to a machine, then copied the
entire Python24 directory to the usb drive.

I have the following in a batch file at the root of the drive:

@path=%PATH%;%CD%Python24;%CD%Python24\libs;%CD%Py thon24\Scripts;%CD%Python24\Lib\site-packages;%CD%Python24\DLLs
@set pythonpath = %CD%Python24
@cmd

When I double click the file and type ''python'' at the prompt I am in a
working python environment, and I am able to import modules in the
site-packages directory (in this case, django).

However, when I run a script directly from the cmd prompt (in this case
''django-admin.py'' the script runs, but fails to import modules from the
site-packages directory.

Is there a command line option to python.exe or an environment variable
I can set to remedy this?

Any other thoughts?

Thanks in advance,
CJL


Jordan:

Thank you for your reply.

If making a usb version of python was that easy, movable python would
be open source.

I knew about movable python, but I''m not using it because it''s not open
source. I guess those guys but some work into it, and feel like a small
fee is appropriate, but I guess I would rather use something open, even
if it means I have to make it myself.

Copying the Python24 directory is a good start, but doesn''t include the
enormous number of registry keys that are included in the install and
are probably needed for the complete capabilites of python.

Is the source of the windows python installer available? I guess I
could see what registry keys they are setting...

Environmental Variables? Try setting the user/system variable "pythonpath"

I do set pythonpath, see above.

Any other ideas?

Thanks again,
CJL


cjl schrieb:

>

I do set pythonpath, see above.

is pythonpath really case insensitive on windows ?


这篇关于从USB驱动器运行python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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