[Tutor] Configure Problems

Charles Takacs genius@idirect.com
Tue, 14 Mar 2000 23:16:46 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_0019_01BF8E0B.5E4AAD40
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am a Newbie with Linux as well as Programming. Trying to lean Python =
as my First language I bought "Learning Python".  Using RH-6.1. I am =
trying to follow the book's instruction but things are not as they =
supposed to be.  The problems seem to be in configuring to use "Module =
Files and Script Files.  I would really appreciate some helping hand.

This is what I did.
1.  For the purpose of Practice in my home directory I created a =
Sub-directory where I want to keep my practice .py files.
as follows;  /home/charly/Mydir
2. In also modified the /home/charly/.bsh_profile  file by adding
        "/home/charly/Mydir:.:"
3.Using Emacs I created as Script file "myfile.py"=20
        (since in my RH distribution Python is in /usr/bin and not in =
/usr/local/bin)
in the file according to the book I typed as follows:
#!/usr/bin/python
print 'Hello World'

Then chmod +x myfile.py=20
could only be donw when I changed to the /home/charly/Mydir directory.

The following problem seem to occur.
1.  To run the file at the "Shell promt" (as a shell script)
    a.   I can only do it if first I cd to the files directory (i.e =
/home/charly/Python)
    b.   I must also add the .py file extension otherwise an error =
occures that=20
            there is no suchfile.  But according to the book the .py =
extension is not=20
            needed.  I also get the error if I try to run the file when =
I am in another dir.

2.  If I am not in the Subdirectory /home/charly/Mydir when I run python =
(in xterm)
        I type :
python
import myfile
         then python gives en error. Hoever if I first cd to the /Mydir =
and type the above. then the Hello World is printed.

I don't know what I am doing wrong to fix this seemingly basic problems.
I was my understanding that Python would find a .py extension file =
regardless of in which directory it is.  also it is my understanding, =
that if a Path is put into the
bash_profile file the the shell would find it and it is not necessary to =
give the
.py extension.

I am completely at loss and need some advice. Thanks in advance.
Charles Takacs




------=_NextPart_000_0019_01BF8E0B.5E4AAD40
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3616.1301"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>I am a Newbie with Linux as well as =
Programming.=20
Trying to lean Python as my First language I bought &quot;Learning=20
Python&quot;.&nbsp; Using RH-6.1. I am trying to follow the book's =
instruction=20
but things are not as they supposed to be.&nbsp; The problems seem to be =
in=20
configuring to use &quot;Module Files and Script Files.&nbsp; I would =
really=20
appreciate some helping hand.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>This is what I did.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>1.&nbsp; For the purpose of Practice =
in my home=20
directory I created a Sub-directory where I </FONT><FONT color=3D#000000 =

size=3D2>want to keep my practice .py files.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>as follows;&nbsp;=20
/home/charly/Mydir</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>2. In also modified the=20
/home/charly/.bsh_profile&nbsp; file by adding</FONT></DIV>
<DIV><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&quot;/home/charly/Mydir:.:&quot;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT size=3D2>3.Using Emacs =
I created as=20
Script file &quot;myfile.py&quot; </FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (since in =
my RH=20
distribution Python is in /usr/bin and not in =
/usr/local/bin)</FONT></DIV>
<DIV><FONT size=3D2>in the file according to the book I typed as=20
follows:</FONT></DIV>
<DIV><FONT size=3D2>#!/usr/bin/python</FONT></DIV>
<DIV><FONT size=3D2>print 'Hello World'</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Then chmod +x myfile.py </FONT></DIV>
<DIV><FONT size=3D2>could only be donw when I changed to the =
/home/charly/Mydir=20
directory.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The following problem seem to occur.</FONT></DIV>
<DIV><FONT size=3D2>1.&nbsp; To run the file at the &quot;Shell =
promt&quot; (as a=20
shell script)</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;=20
a.&nbsp;&nbsp; I can only do it if first I cd to the files directory =
(i.e=20
/home/charly/Python)</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; b.&nbsp;&nbsp; I =
must also=20
add the .py file extension otherwise an error occures that </FONT></DIV>
<DIV><FONT color=3D#000000=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; there=20
is no suchfile.&nbsp; But according to the book the .py extension is not =

</FONT></DIV>
<DIV><FONT color=3D#000000=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
needed.&nbsp; I also get the error if I try to run the file when I am in =
another=20
dir.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>2.&nbsp; If I am not in the Subdirectory =
/home/charly/Mydir=20
when I run python (in xterm)</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I type =
:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>python</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>import myfile</FONT></DIV>
<DIV><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
then python gives en error. Hoever if I first cd to the /Mydir and type =
the=20
above. then the Hello World is printed.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I don't know what I am doing wrong to fix this =
seemingly basic=20
problems.</FONT></DIV>
<DIV><FONT size=3D2>I was my understanding that Python would find a .py =
extension=20
file regardless of in which directory it is.&nbsp; also it is my =
understanding,=20
that if a Path is put into the</FONT></DIV>
<DIV><FONT size=3D2>bash_profile file the the shell would find it and it =
is not=20
necessary to give the</FONT></DIV>
<DIV><FONT size=3D2>.py extension.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I am completely at loss and need some advice. Thanks =
in=20
advance.</FONT></DIV>
<DIV><FONT size=3D2>Charles Takacs</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0019_01BF8E0B.5E4AAD40--