Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
connot write to sys.stderr
#1
I am using Eclipse IDE and doing Run As -> Pyton Run "inquiry.py"
It fails in "site.py".

I know what is the function of site.py.

My question is

why is writing error to stderr disabled?

Is that python specific and why ?


This is the site.py code throwing the exception:

         except Exception:
                print("Error processing line {:d} of {}:\n".format(n+1, fullname),
                      file = sys.stderr)
                import traceback
Here is the Eclipse error

Error:
Parent of resource: /usr/lib/python3.7/site.py is marked as read-only. /usr/lib/python3.7/site.py (Permission denied)
Reply
#2
The error is never in a standard library module (under /usr/lib/python3.7). The error is somewhere in your code, so it is most likely in your file inquiry.py. Don't try to change the standard library's modules code.

The piece of code that you wrote above in site.py is run when python is trying to read a .pth file. Did you write some .pth file?
Please post the entire error message and traceback and try to find the line where it fails in your code.
Reply
#3
Sorry,
the "inquiry.py" came with PyBluez. I did not write it.

What you are saying is "stderr" has to be enabled, as indicated.

This is the only error I get and my guess
is it is serious enough that the code terminates.

So the question is - how do I enable stderr or in C language terminology "stdio" ?

PS I am still not getting my e-mails notifications - I have to manually access this forum

Addendum
I am unable to just "save all" in my IDE , getting this error.
The question needs to be asked

how / why /usr/lib/python3.7/site.py is read only ?

Yes, I can change the file permissions, but why is it that way in first place ?
I am tempted to reinstall pyton3.7 - who knows what else is wrong with current install.




Quote:Parent of resource: /usr/lib/python3.7/site.py is marked as read-only.
/usr/lib/python3.7/site.py (Permission denied)
Reply
#4
/usr/lib/python3.7/site.py is read-only because it is a file from the systemwide install of python that you as a user are not supposed to edit. You shouldn't have edited site.py and the editor cannot write this file if the editor is not ran as administrator. Editing site.py can only result in corrupting your install of python.

Stderr does not need to be activated in python. You are misinterpreting the error.
Reply
#5
/usr/lib/python3.7/site.py is read-only because it is a file from the systemwide install of python that you as a user are not supposed to edit. You shouldn't have edited site.py and the editor cannot write this file if the editor is not ran as administrator. Editing site.py can only result in corrupting your install of python.

Stderr does not need to be activated in python. You are misinterpreting the error.


OK, why I cannot "save all" as always?
Answer that first. Please.



I will pass on sdterr - the code wants to post / write an error and it cannot due to permissions of "system wide " file .

Since you pointed out it is my misinterpretation , there is no need to further elaborate on this . Case closed..
.
Reply
#6
If you try to "Save all" but you modified in the editor a buffer opened on a read-only file, the 'Save all' will fail because the editor won't be able to overwrite the read-only file. That's how I understand the error.

You can test this by yourself: create a text file, then close the editor, make the file read-only, restart the editor, open the file, edit and try to Save All. Is it the same error?
Reply
#7
I suspect the IDE. What happens if you try to run from a command shell? I think your IDE is trying to save the .py file you are trying to run.
Reply
#8
Try:
1.Make sure Python is enabled in Eclipse
2. Run the install as root.
3. Chmod, chown the the file script file (but not the python system files).
3. An obscure error I have come across when dealing with .pth files is a requirement for the first statement semicolon to be followed by a newline.
import sys, types, os;has_mfs = sys.version_info .... 
becomes

import sys, types, os;
has_mfs = sys.version_info 
4. Run it in idle. Permission Denied type messages are often issued if the system cannot *find* the files it needs. Idle *should* find them. Eclipse not so much.
5. Site.py *should* be immutable (read/only).
6. Check your path to make sure no other version installs precede 3.7. Also, check your PYTHONPATH var.
7. More experienced users may want to verify this, but: I get the impression that when installing modules all the requierements are taken from the METADATA files, and not from the script import statements. Sometimes there is a difference which can lead to some strange errors. Especially with a Bluetooth app, make sure all your dependencies are actually installed. In Python, as well as your OS distro. (Install bluetooth apps, *and* their 'dev' lib files. )
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [subprocess] Why stdout sent to stderr? Winfried 3 553 Jan-26-2024, 07:26 PM
Last Post: snippsat
  stderr redirect to file fmr300 2 3,686 Apr-03-2021, 01:31 AM
Last Post: fmr300
  changing stdout and stderr Skaperen 4 2,758 Dec-02-2020, 08:58 PM
Last Post: Skaperen
  how to output to stderr from inside a generator? Skaperen 2 1,871 Mar-03-2020, 03:17 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020