473,770 Members | 7,229 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
18 6779
Thorsten Kampe wrote:
* 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
Sigh. Right, the semantics are actually inside the subsystem accessing
the filesystem, if I have to dot every I and cross every T. Note that
the reference you quote includes the test """However, if you attempt to
open one of these files in a Win32 application, such as Notepad, you
would only have access to one of the files, regardless of the case of
the filename you type in the Open File dialog box."""

So perhaps I should have said the Win32 API implements case-insensitive
semantics? Sure, if you want to use the POSIX compatibility layer it's
absolutely possible to create several files that Win32 applications will
be completely unable to distinguish between. Whatever good that might do
you.

Sheesh, the nits that get picked on this list nowadays. I can remember
when it used to be fun, not an exercise in ego inflation.

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 12 '06 #11
* Steve Holden (2006-09-12 01:30 +0100)
Thorsten Kampe wrote:
>* 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

Sigh. Right, the semantics are actually inside the subsystem accessing
the filesystem, if I have to dot every I and cross every T. Note that
the reference you quote includes the test """However, if you attempt to
open one of these files in a Win32 application, such as Notepad, you
would only have access to one of the files, regardless of the case of
the filename you type in the Open File dialog box."""

So perhaps I should have said the Win32 API implements case-insensitive
semantics? Sure, if you want to use the POSIX compatibility layer it's
absolutely possible to create several files that Win32 applications will
be completely unable to distinguish between. Whatever good that might do
you.

Sheesh, the nits that get picked on this list nowadays. I can remember
when it used to be fun, not an exercise in ego inflation.
It's exactly the same issue as with the environment variables: "You
live and learn."[1]

Thorsten
[1] http://groups.google.com/group/comp....9fa3ce96e757b3
Sep 12 '06 #12
cjl
Hey all:

I'm getting closer. My startpython.bat file is now:

path=%PATH%;%CD %Python24;%CD%P ython24\libs;%C D%Python24\Scri pts;%CD%Python2 4\Lib\site-packages;%CD%Py thon24\DLLs
set PYTHONPATH=%CD% Python24
ASSOC .py=Python.File
ASSOC .pyc=Python.Com piledFile
ASSOC .pyo=Python.Com piledFile
ASSOC .pyw=Python.NoC onFile
FTYPE Python.File=%CD %Python24\pytho n.exe "%1" %*
FTYPE Python.Compiled File=%CD%Python 24\python.exe "%1" %*
FTYPE Python.NoConFil e=%CD%Python24\ pythonw.exe "%1" %*
set PATHTEXT=%PATHT EXT%;.py;.pyc;. pyo;.pyw
cmd

I am having a problem with the ftype commands as written above. If I
type them from the command line exactly like above they work. But for
some reason they do not work from my batch file. Anyone familiar with
bath file syntax that can help me? I am very close here...

Thanks again,
CJL

Sep 12 '06 #13
cjl
Hey all:

It seems no matter what I do the %1 gets replaced by paramaters sent to
the batch file...there must be some way of "escaping" this, but I can't
find the answer (yet) with google. Anyone?

-CJL

Sep 12 '06 #14
cjl wrote:
Hey all:

It seems no matter what I do the %1 gets replaced by paramaters sent to
the batch file...there must be some way of "escaping" this, but I can't
find the answer (yet) with google. Anyone?

-CJL
Use two percents in a row turn into a single percentage sign. So you'd
want "%%1".

--Jason

Sep 12 '06 #15
cjl
Jason:

Thanks! That worked...in fact, almost everything is now working as
expected (so far).

Here is my batch file:

echo "Making changes to path and file associations... "
path =
%PATH%;%CD%Pyth on24;%CD%Python 24\libs;%CD%Pyt hon24\Scripts;% CD%Python24\Lib \site-packages;%CD%Py thon24\DLLs
set PYTHONPATH=%CD% Python24
ASSOC .py=Python.File
ASSOC .pyc=Python.Com piledFile
ASSOC .pyo=Python.Com piledFile
ASSOC .pyw=Python.NoC onFile
FTYPE Python.File=%CD %Python24\pytho n.exe "%%1" %%*
FTYPE Python.Compiled File=%CD%Python 24\python.exe "%%1" %%*
FTYPE Python.NoConFil e=%CD%Python24\ pythonw.exe "%%1" %%*
set PATHTEXT=.py;%P ATHTEXT%
CMD

I'm still having a problem with setting PATHTEXT...I should be able to
now type django-admin at the cmd prompt and have it work, but I need to
still type django-admin.py ... I'm not sure what's wrong with my
setting of pathtext.

Any ideas?

Thanks again,
CJL

Sep 12 '06 #16
* cjl (2006-09-12 13:10 +0100)
Jason:

Thanks! That worked...in fact, almost everything is now working as
expected (so far).

Here is my batch file:

echo "Making changes to path and file associations... "
path =
%PATH%;%CD%Pyth on24;%CD%Python 24\libs;%CD%Pyt hon24\Scripts;% CD%Python24\Lib \site-packages;%CD%Py thon24\DLLs
set PYTHONPATH=%CD% Python24
ASSOC .py=Python.File
ASSOC .pyc=Python.Com piledFile
ASSOC .pyo=Python.Com piledFile
ASSOC .pyw=Python.NoC onFile
FTYPE Python.File=%CD %Python24\pytho n.exe "%%1" %%*
FTYPE Python.Compiled File=%CD%Python 24\python.exe "%%1" %%*
FTYPE Python.NoConFil e=%CD%Python24\ pythonw.exe "%%1" %%*
set PATHTEXT=.py;%P ATHTEXT%
CMD

I'm still having a problem with setting PATHTEXT...I should be able to
now type django-admin at the cmd prompt and have it work, but I need to
still type django-admin.py ... I'm not sure what's wrong with my
setting of pathtext.
Setting environment variables has only effect on the process itself
and the subprocesses. This has nothing to do with Windows, it's the
same with Linux.
Sep 12 '06 #17
cjl
Thorsten:

Thank you for your reply.
Setting environment variables has only effect on the process itself
and the subprocesses. This has nothing to do with Windows, it's the
same with Linux.
True, and the changes to path and pythonpath are gone after I close the
console window, but the results of the assoc and ftype commands are
changes to the registry that linger. If I run my setup on a computer
that has python installed, I will overwrite the pre-existing registry
settings. I can restore them with a script, but I can't guarantee that
my restore script will run.

I'm still looking for a way to modify these temporarily, but it looks
like I might be "up the creek" on this one. Oh well.

Thanks again,
CJL

Sep 12 '06 #18
cjl wrote:
Thorsten:

Thank you for your reply.
Setting environment variables has only effect on the process itself
and the subprocesses. This has nothing to do with Windows, it's the
same with Linux.

True, and the changes to path and pythonpath are gone after I close the
console window, but the results of the assoc and ftype commands are
changes to the registry that linger. If I run my setup on a computer
that has python installed, I will overwrite the pre-existing registry
settings. I can restore them with a script, but I can't guarantee that
my restore script will run.

I'm still looking for a way to modify these temporarily, but it looks
like I might be "up the creek" on this one. Oh well.

Thanks again,
CJL
I notice that you've already got the environmental variables set up to
run your Temp-Python. You can retrieve the current associations (if
any) by using the assoc and ftype commands:

C:\>assoc .py
..py=Python.Fil e

C:\>ftype Python.File
Python.File="C: \Python24\pytho n.exe" "%1" %*

C:\>assoc .NotAnExtension
File association not found for extension .NotAnExtension

C:\>

Using this information, you could write a little python script with
your distribution which records the current file associations and
settings. Then, when you're ready to revert, you run another little
python script which restores the associations.

These associations are also stored in the registry. You could back up
the registry keys which you know will be modified, make the registry
changes yourself, and restore the registry settings at finish. It
would require Python's win32 extension modules, though.

I don't know how you could do it without using a
backup/run-stuff/restore sequence.

--Jason

Sep 13 '06 #19

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

Similar topics

5
1995
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
1681
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
9592
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
10230
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10058
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10004
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
8886
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
7416
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
6678
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();...
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.