473,762 Members | 8,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running python from a usb drive

cjl
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%;%C D%Python24;%CD% Python24\libs;% CD%Python24\Scr ipts;%CD%Python 24\Lib\site-packages;%CD%Py thon24\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

Sep 11 '06 #1
18 6778
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%;%C D%Python24;%CD% Python24\libs;% CD%Python24\Scr ipts;%CD%Python 24\Lib\site-packages;%CD%Py thon24\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
Sep 11 '06 #2
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

Sep 11 '06 #3
cjl schrieb:
>

I do set pythonpath, see above.
is pythonpath really case insensitive on windows ?
Sep 11 '06 #4
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\Projec ts\Python\dbimp >dir DB.py
Volume in drive C has no label.
Volume Serial Number is 9CA8-2A02

Directory of C:\Steve\Projec ts\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\Projec ts\Python\dbimp >dir db.py
Volume in drive C has no label.
Volume Serial Number is 9CA8-2A02

Directory of C:\Steve\Projec ts\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

Sep 11 '06 #5
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
Sep 11 '06 #6
cjl
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\Script s 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\dja ngo-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

Sep 11 '06 #7
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\Projec ts\Python\dbimp >set SCREWUP="This is Windows"

C:\Steve\Projec ts\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

Sep 11 '06 #8
* 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...
>Environmenta l Variables? Try setting the user/system variable "pythonpath "

I do set pythonpath, see above.

Any other ideas?
Use Cywin Python.
Sep 11 '06 #9
* 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
Sep 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1993
by: Ben Finney | last post by:
Howdy all, I'm experimenting with carrying my personal computing environment around on a keychain USB flash storage device. I have the usual suspects on there: SSH keys, GPG keys, program configs. I'm probably not the first to think that a standalone distribution of Python would be a useful thing to have in my back pocket. Finding information on that is proving to be a problem, however.
3
5902
by: hepp | last post by:
Is it possible to run a Python script in Windows without installing Python on your machine first? At my work we are using a mixed environment - some have Solaris workstations and others PC's. I have written an application in wxPython that runs in both Unix and Solaris. For the Unix version I put an installation of Python on a network drive that everybody can access, but in Windows everybody has to download Python and wxPython before...
17
4008
by: los | last post by:
Hi, I'm trying to create a program similar to that of Google's desktop that will crawl through the hard drive and index files. I have written the program and as of now I just put the thread to sleep for 1 second after indexing a couple of files. I'm wondering if anyone knows of a way that I could make so that the program will run at full speed only runs after the computer has been idle for a while. I've looked at the "nice" command...
6
1679
by: planetthoughtful | last post by:
Hi All, I've written my first piece of practical Python code (included below), and would appreciate some comments. My situation was that I had a directory with a number of subdirectories that contained one or more zip files in each. Many of the zipfiles had the same filename (which is why they had previously been stored in separate directories). I wanted to bring all of the zip files (several hundrd in total) down to the common parent...
3
1956
by: James Stroud | last post by:
Hello All, I am helping someone write a python script to run their DOS application through an SSH terminal. It seems that this program wants to access a DOS shell and send output there. If running remotely, this causes a problem because it locks up the program. The program seems (to me) to be looking for some non-existant DOS shell to send its output to. How might I emulate this shell (or whatever it is) with python? I have tried...
3
1767
by: Gregory Piñero | last post by:
Just thought I'd see if you guys had an answer for this. My website analytics page shows that people come to my site after searching for "Python drive name" but I don't think I'm offering any help with such a thing. However I would like to help since I'm getting a few people a day for this. So does anyone have an idea on what they could be searching for ..... and of course what the answer would be? Sorry it's such a vague question...
1
1640
by: Warren | last post by:
I am running win2k pro and was wondering if writing python scripts or running modules dumps anything in the "C" drive? I have 3 partitions and run python on the 3rd one or "E"drive. My "C" drive is almost full and keeps loading up with stuff I don't want or need. Some of it I can find some not. So until I can get a new HD I need to keep weeding out the weeds! TIA. Warren
3
3837
by: Putty | last post by:
Is there such a thing as a special version of python that I can run more efficiently from a flash drive? I'll be at college for hours every day with hours of free time for the next few months, but the only computers at my disposal are windows PCs that use GoBack to auto-revert every reboot. So I'm kinda stuck. I don't want to have to reinstall python AND wxPython AND PIL every stinking time I log on. However, using it from my flash...
7
2368
by: W. eWatson | last post by:
I copied the following code from a matplotlib tutorial, and it fails. I'm using python 2.4 on Win XP. It's matplotlib-0.98.3.win32-py2.4exe. It fails in IDLE with a small window showing a runtime error. Clicking the OK on it kills IDLE and the shell. If I double-click on the py file, the console briefly appears too quickly to notice any contents. I have read raw to stop it. If I execute it from a console window, I'm told the results will be...
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9927
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.