473,468 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Python search path (on Windows)

I would like to execute a Python script from Windows command line:

Python myscript.py

This works if myscript.py resides in the current folder. My question is:
Is it possible to execute the command above from another folder?

I put the script's folder in the PYTHONPATH environment variable but this
didn't help.

Thanks for your help!
Oct 22 '08 #1
3 2296
En Wed, 22 Oct 2008 07:03:48 -0200, wooly booly <wb@noname.comescribió:
I would like to execute a Python script from Windows command line:

Python myscript.py

This works if myscript.py resides in the current folder. My question is:
Is it possible to execute the command above from another folder?
Yes, use:
python path\to\the\actual\location\of\myscript.py
I put the script's folder in the PYTHONPATH environment variable but this
didn't help.
No, PYTHONPATH contains the directories searched when trying to import a
module -- it's not used to locate the main script.

--
Gabriel Genellina

Oct 22 '08 #2
wooly booly wrote:
I would like to execute a Python script from Windows command line:

Python myscript.py

This works if myscript.py resides in the current folder. My question is:
Is it possible to execute the command above from another folder?

I put the script's folder in the PYTHONPATH environment variable but this
didn't help.
Then you could try

Python -m myscript

Diez
Oct 22 '08 #3
Ant
On Oct 22, 10:03*am, "wooly booly" <w...@noname.comwrote:
I would like to execute a Python script from Windows command line:

Python myscript.py

This works if myscript.py resides in the current folder. My question is:
Is it possible to execute the command above from another folder?

I put the script's folder in the PYTHONPATH environment variable but this
didn't help.

Thanks for your help!
You can put the script directory in the PATH environment variable, and
call it with just:

myscript.py
Oct 22 '08 #4

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

Similar topics

3
by: Peter Schwalm | last post by:
I'd like to modify the python search path depending on the source directory of the script being started. The reason is: I use a version control system, and the python scripts and modules are...
0
by: John Salerno | last post by:
Is there a way for me to somehow specify that I want Python to search all subdirectories of a particular directory when I'm running or testing files from the command prompt? For example, I have...
0
by: h112211 | last post by:
Hi, Does anyone have any clues why I can import a module (pgdb) from the python command line, but trying to run a script doing it from IDLE I get "ImportError: DLL load failed: The specified...
1
by: aznach | last post by:
Hello! I have a shared hosting account at GrokThis.net and have a problem with the module order of the Python search path. I'd like to use django's svn trunk instead of the...
2
by: Tomasz Jastrzebski | last post by:
Hi All, Is there any way I can specify additional dll search path, preferably in web.config, which would be used by asp.net 2.0 when binding assemblies? I have many dlls shared among...
1
by: mhearne808[insert-at-sign-here]gmail[insert-dot-he | last post by:
I think I don't understand how the module search path works... Let's say I have a folders called 'test'. Underneath it, I create two more folders called 'foo' and 'bar'. In 'foo', I create an...
8
by: tow | last post by:
I have a python script (part of a django application, if it makes any difference) which is exhibiting the following behaviour: import my_module # succeeds imp.find_module("my_module") # fails,...
0
by: Gabriel Genellina | last post by:
En Wed, 20 Aug 2008 17:10:15 -0300, aditya shukla <adityashukla1983@gmail.comescribió: You have 3 leading underscores in __main__ so the if statement is skipped and nothing happens. I'd use the...
2
by: Mike Driscoll | last post by:
On Sep 25, 10:41 am, js <ebgs...@gmail.comwrote: Why not just add a custom path file (*.pth)? EasyInstall, wx, PyWin32 and others do it. Of course there's always sys.path.append as well. Mike
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
1
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...
0
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...
0
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,...
1
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...
0
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.