473,372 Members | 1,067 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,372 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 3431
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.