473,584 Members | 2,819 Online
Bytes | Software Development & Data Engineering Community
+ 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 2311
En Wed, 22 Oct 2008 07:03:48 -0200, wooly booly <wb@noname.come scribió:
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\act ual\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.co mwrote:
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
2355
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 migrated through several stages before they are used in production. A python script running in a development environment should use different modules -...
0
980
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 a folder in my C:\Python24 folder called myscripts\. At first I saved my scripts in there, since there weren't many, and any work I did from the...
0
1217
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 module could not be found."? How does the search path differ between IDLE and the Python command line?
1
1546
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 "Django-0.95-py2.4.egg" provided in site-packages. The problem is that the "django egg" gets preference over the "django svn trunk" module I manually added to...
2
6727
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 applications and I prefer not to add them to the GAC, but also I do not want to keep/manage multiple copies in every web application's folder. Thank you for...
1
1458
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 empty '__init__.py' file, indicating that this folder is a package 'foo'. I then create a simple python script 'foo.py' consisting of the...
8
1556
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, raising ImportError which is completely baffling me. According to sys.path, both should fail; the directory containing my_module is not in sys.path...
0
1318
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 split method of string objects, and there is no need for a file_found variable: def search_file(filename, search_path): """Given a search path,...
2
1736
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
7829
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...
0
8189
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. ...
0
8330
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...
0
6587
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...
1
5705
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...
0
5379
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...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2336
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
0
1162
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...

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.