I'm new to python, running it under cygwin. This must be easy but I
haven't figured it out. I'm trying to run a script by typing:
python test.py
where test.py is in a directory I've added to PYTHONPATH, but test.py
is not found. Perhaps PYTHONPATH only applies to modules imported
within a script. I didn't notice an option to python to search the
standard path, like Perl -S.
How is this done? 5 1900
On Sep 12, 4:40 pm, grt <gary.thr...@na vy.milwrote:
>
I'm trying to run a script by typing:
python test.py
What happens if you just type:
test.py or test
and hit Enter?
rd
On Sep 12, 4:06 pm, BartlebyScriven er <bscrivene...@g mail.comwrote:
On Sep 12, 4:40 pm, grt <gary.thr...@na vy.milwrote:
I'm trying to run a script by typing:
python test.py
What happens if you just type:
test.py or test
and hit Enter?
rd
test gives the error: command not found.
test.py gives the error: no such file.
grt wrote:
I'm new to python, running it under cygwin. This must be easy but I
haven't figured it out. I'm trying to run a script by typing:
python test.py
where test.py is in a directory I've added to PYTHONPATH, but test.py
is not found. Perhaps PYTHONPATH only applies to modules imported
within a script. I didn't notice an option to python to search the
standard path, like Perl -S.
How is this done?
The PYTHONPATH is only used to augment sys.path, which in turn is only
used for locating modules to import.
If you want to locate scripts then just put them on your PATH, and make
sure they are +x with a shebang line (#!/usr/bin/env python is the
commonest) at the head.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Am Wed, 12 Sep 2007 14:40:30 -0700 schrieb grt:
I'm new to python, running it under cygwin. This must be easy but I
haven't figured it out. I'm trying to run a script by typing:
python test.py
where test.py is in a directory I've added to PYTHONPATH, but test.py
is not found. Perhaps PYTHONPATH only applies to modules imported
within a script. I didn't notice an option to python to search the
standard path, like Perl -S.
How is this done?
python -m test
Peter
This works for me under cygwin.
Start the script with the line
#! /usr/bin/python
Place the script in a directory shown by the command
echo $PATH
Invoke the script using its name, i.e.
test.py This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephen Ferg |
last post by:
I need a little help here.
I'm developing some introductory material on Python for non-programmers.
The first draft includes this statement. Is this correct?
-----------------------------------------------------------------
When loading modules, Python looks for modules
in the following places in the following order:
|
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 - possibly in other directories then the script source
directory - than the same script running in a...
|
by: Darren Dale |
last post by:
Is there a place to put python programs so I dont have to refer to the
absolute path everytime I want to call them? For example:
if I am in /home/me and want to execute:
python /home/me/python/export.py temp.dat
what could I do so this will work:
python export.py temp.dat
|
by: Les Juby |
last post by:
A year or two back I needed a search script to scan thru HTML files
on a client site. Usual sorta thing. A quick search turned up a
neat script that provided great search results. It was fast,
returned the hyperlinked page title, filename, and the body txt (30
preceding and following words) in context with the search word
highlighted. Excellent.!
See it working at: http://www.ipt.co.za
Just search for "firearm"
|
by: PipedreamerGrey |
last post by:
This is the beginning of a script that I wrote to open all the text
files in a single directory, then process the data in the text files
line by line into a single index file.
os.chdir("C:\\Python23\\programs\\filetree")
mydir = glob.glob("*.txt")
index = open("index.rtf", 'w')
for File in mydir:
| |
by: boris |
last post by:
I have two directories, lib1 and lib2, that both contain the package
foo, one with the submodule mod1
and the other with the submodule mod2:
$ ls lib*/foo/
lib1/foo/:
__init__.py __init__.pyc mod1.py mod1.pyc
lib2/foo/:
__init__.py __init__.pyc mod2.py mod2.pyc
|
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 following code:
----------------------------
|
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 (though
the my_module directory itself is). More puzzlingly, printing out
my_module.__file__...
|
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
|
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...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
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...
| |
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...
| |