Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Running python from a usb drive

Reply
Thread Tools

Running python from a usb drive

 
 
cjl
Guest
Posts: n/a
 
      09-11-2006
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

 
Reply With Quote
 
 
 
 
Jordan
Guest
Posts: n/a
 
      09-11-2006
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


 
Reply With Quote
 
 
 
 
cjl
Guest
Posts: n/a
 
      09-11-2006
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

 
Reply With Quote
 
Uwe Hoffmann
Guest
Posts: n/a
 
      09-11-2006
cjl schrieb:

>
>
> I do set pythonpath, see above.
>

is pythonpath really case insensitive on windows ?
 
Reply With Quote
 
Steve Holden
Guest
Posts: n/a
 
      09-11-2006
Uwe Hoffmann wrote:
> cjl schrieb:
>
>
>>
>>I do set pythonpath, see above.
>>

>
> is pythonpath really case insensitive on windows ?


Only because the Windows filesystem implements case-insensitive
semantics. This is nothing to do with Python:

C:\Steve\Projects\Python\dbimp>dir DB.py
Volume in drive C has no label.
Volume Serial Number is 9CA8-2A02

Directory of C:\Steve\Projects\Python\dbimp

01/19/2005 06:03 PM 136 db.py
1 File(s) 136 bytes
0 Dir(s) 15,908,880,384 bytes free

C:\Steve\Projects\Python\dbimp>dir db.py
Volume in drive C has no label.
Volume Serial Number is 9CA8-2A02

Directory of C:\Steve\Projects\Python\dbimp

01/19/2005 06:03 PM 136 db.py
1 File(s) 136 bytes
0 Dir(s) 15,908,880,384 bytes free


regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

 
Reply With Quote
 
cjl
Guest
Posts: n/a
 
      09-11-2006
Uwe:

Thank you for your reply.

> is pythonpath really case insensitive on windows ?


I think so. After running my batch file, I can load the python
interpreter by typing 'python', and can then type 'import django'
without error. This lives in the site-packages directory, so it is
finding it.

However, there is a python script that lives in python24\Scripts called
'django-admin.py', which I am adding to my path. When I type
'django-admin.py --help' I get an error that it couldn't load the
django module. When I type 'python E:\python24\django-admin.py --help'
I get the correct output, and no errors, so I know it is loading the
module.

I guess I am trying to figure out why, and what the top "shebang" line
should be for the script django-admin.py, because the removable drive
can have different drive letters, so I can't hard code it.

thanks again,
CJL

 
Reply With Quote
 
Uwe Hoffmann
Guest
Posts: n/a
 
      09-11-2006
Steve Holden schrieb:
> Uwe Hoffmann wrote:
>
>> cjl schrieb:
>>
>>
>>>
>>> I do set pythonpath, see above.
>>>

>>
>> is pythonpath really case insensitive on windows ?

>
>
> Only because the Windows filesystem implements case-insensitive
> semantics. This is nothing to do with Python:


no, i mean't the name not the content. Is the handling of the
env variable pythonpath case insensitive: pythonpath <--> PYTHONPATH.

regards
uwe
 
Reply With Quote
 
Steve Holden
Guest
Posts: n/a
 
      09-11-2006
Uwe Hoffmann wrote:
> Steve Holden schrieb:
>
>>Uwe Hoffmann wrote:
>>
>>
>>>cjl schrieb:
>>>
>>>
>>>
>>>>I do set pythonpath, see above.
>>>>
>>>
>>>is pythonpath really case insensitive on windows ?

>>
>>
>>Only because the Windows filesystem implements case-insensitive
>>semantics. This is nothing to do with Python:

>
>
> no, i mean't the name not the content. Is the handling of the
> env variable pythonpath case insensitive: pythonpath <--> PYTHONPATH.
>

You live and learn. Apparently it is:

C:\Steve\Projects\Python\dbimp>set SCREWUP="This is Windows"

C:\Steve\Projects\Python\dbimp>python
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
Started with C:/Steve/.pythonrc
>>> import os; print os.environ["screwup"]

"This is Windows"
>>>


It turns out that there's code in os.py specifically for os2 and NT
systems, wherein a subclass of userDict is declared that used
case-insensitive pattern matching:

>>> os.environ.__class__

<class os._Environ at 0x0098CCC0>
>>>


regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

 
Reply With Quote
 
Thorsten Kampe
Guest
Posts: n/a
 
      09-11-2006
* cjl (2006-09-11 20:34 +0100)
>> 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...


Simply installing Python would be about one hundred times faster...

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

>
> I do set pythonpath, see above.
>
> Any other ideas?


Use Cywin Python.
 
Reply With Quote
 
Thorsten Kampe
Guest
Posts: n/a
 
      09-11-2006
* Steve Holden (2006-09-11 21:37 +0100)
> Uwe Hoffmann wrote:
>> cjl schrieb:
>>>I do set pythonpath, see above.

>>
>> is pythonpath really case insensitive on windows ?

>
> Only because the Windows filesystem implements case-insensitive
> semantics. This is nothing to do with Python:


That's nonsense: "Filenames are Case Sensitive on NTFS Volumes"[1]

Thorsten
[1] http://support.microsoft.com/kb/100625/en-us
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Running python from a usb drive Tim Golden Python 0 09-12-2006 02:14 PM
RE: Running python from a usb drive Tim Golden Python 3 09-12-2006 01:47 PM
Re: USB issue ... some USB 2 ports working only in USB 1 mode hungsolo2005@yahoo.com A+ Certification 0 06-14-2006 07:26 PM
USB Flash Memory Stick <-> USB External Hard Drive Conflict Eli Coten Computer Information 0 03-30-2006 08:28 PM
Swissbit Cirrus WHITE USB 512mb USB Drive @ ThinkComputers.org Silverstrand Front Page News 0 01-20-2006 02:49 AM



Advertisments