473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

help - python can't find file

-learning python with limited knowledge of linux.
-get error msg 21 "file or directory does not exist"
-running Suse linux 10.
-haven't had a problem before
- rebooted several times.
-python opened in shell/terminal program Konsole window like this
user1@linux!~ - shell - Konsole
Sessions View Bookmark Settings Help

-first line in window gives me a linux prompt:
user1#linux:~>

- whereupon I type python and get >>a command line I think it is
called or type python pyfilename.py and it runs/interprets/opens
the file on screen

- but now I get a error message 21 saying file or directory doesn't
exist.

- my py files are created with editor gedit
- clicking on any py file and linux asks me to open it with what
program and I choose utilities/editdors/gedit and it works.

-all my py files contain the following lines at the beginning
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# filename: blankpy.py (for example of a file name)
- my linux file structure is as follows shown under Konqueror window:
rootfolder
bin
boot
dev
etc
home
user1
bin
desktop
documents
lib
media
dvdrecorder
floppy

- (for example, and continues on, of course)
- none of my python books or linux books show that I can type
python /dev/sda/ blankpy.py and get python to open it like in
windows98 or dos python A:\blankpy.py

embarrassed and frustrated
May 21 '07 #1
2 3435
quoth the enquiring mind:
- but now I get a error message 21 saying file or directory doesn't
exist.
You must be in the same directory (in konsole) as the python script for this
to work, else enter the relative path to the file:

Assuming you are in your home directory (this is where a new konsole will
start you), and the py scripts are in a directory 'pythondir':

$ cd pythondir
$ python myscript.py

or:

$ python pythondir/myscript.py

You could also chmod the script to be executable and run it as a regular
command ...however... I don't mean this to sound like RTFM but I do think
that you could use some reading on Linux CLI usage. You say you have some
Linux books?

I say this as my reading of your message indicates your problems lie with
misunderstanding the shell/paths etc, not with Python itself...

-d
--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
May 21 '07 #2
darren,

thanks for your explanation. I copied my paths and listed them in my
code file
#! /bin/user1/ python

and python finds the file and interprets it so that will keep me going
until my buddy returns to the city to explain my errors. It appears
that my problem arose from taking lesson code out of text books and
copying the pathing that is I guess slightly different than mine.

Thanks ever so much.
tk

darren kirby wrote:

>
quoth the enquiring mind:
- but now I get a error message 21 saying file or directory doesn't
exist.

You must be in the same directory (in konsole) as the python script for this
to work, else enter the relative path to the file:

Assuming you are in your home directory (this is where a new konsole will
start you), and the py scripts are in a directory 'pythondir':

$ cd pythondir
$ python myscript.py

or:

$ python pythondir/myscript.py

You could also chmod the script to be executable and run it as a regular
command ...however... I don't mean this to sound like RTFM but I do think
that you could use some reading on Linux CLI usage. You say you have some
Linux books?

I say this as my reading of your message indicates your problems lie with
misunderstanding the shell/paths etc, not with Python itself...

-d
--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
May 22 '07 #3

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
10
by: Jacek Generowicz | last post by:
Where can I find concise, clear documentation describing what one has to do in order to enable Python's internal help to be able to provide descriptions of Python keywords ? I am in a situation...
5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
5
by: jester.dev | last post by:
Hello, I'm learning Python from Python Bible, and having some problems with this code below. When I run it, I get nothing. It should open the file poem.txt (which exists in the current...
4
by: Active8 | last post by:
I did this once and can't remember how <blush> so I read the reportlab user guid. It says to unzip the reportlab archive - this is on w2k, BTW, with Python23 - to a directory and make a file...
10
by: svenn.are | last post by:
Hi, I wanted to run a program that is written in PyQt on my mac, and went over to Riverbank to get PyQ 3.13 and SIP 4.1.1 sources. I followed the installation guide except for the compiling...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
1
by: Paul Rubin | last post by:
In Windows if you click the Help dropdown, IDLE launches a help window as it should. The help contents are included in the installation. In Linux, clicking Help launches a web browser, which is...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
2
by: astrogirl77 | last post by:
Hi, I'm new to Python and am hoping to find help with coding a Python script, applet. I code in an old version of Visual Basic 4.0, I have a simple app that is about 3 and a half pages of code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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,...

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.