I’m trying to connect music21, a Python “toolkit for computer-aided musicology”, to Musescore. To do so, the music21.environment.UserSettings() function has a setting to define a path to Musescore, which checks if the file exists with os.path.exists(value). In Fedora, the rpm installs Musescore to /usr/bin/mscore, but os.path.exists("/usr/bin/mscore") returns False, even though the file exists.
In the documentation of os.path.exists, it is specified that
That part looks right.
On my fedora 36 machine the python functions you gave work properly so more info, including exactly what is seen when starting the app, (full details) is needed.
To confirm it is the function returning false or something else try what I did.
[jvian@laptop ~]$ python -V
Python 3.10.4
[jvian@laptop ~]$ python
Python 3.10.4 (main, Mar 25 2022, 00:00:00) [GCC 12.0.1 20220308 (Red Hat 12.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print( os.path.exists("/usr/bin/head"))
True
>>> print( os.stat("/usr/bin/head"))
os.stat_result(st_mode=33261, st_ino=684414, st_dev=64768, st_nlink=1, st_uid=0, st_gid=0, st_size=45912, st_atime=1650894271, st_mtime=1647850427, st_ctime=1650894246)
This clearly shows that my regular user is able to read the stats and that python sees the file.
For trouble shooting you need more detail than has been provided about the messages you are receiving.
Interesting. I tried with the system python, the Anaconda python distribution, conda environments, python, ipython and Jupyter lab. They all… return True to os.path.exists("/usr/bin/mscore")! The only way I obtain False is with the Jupyter implementation of VSCode, so I guess ths is an issue on their side. Problem solved! Thanks a lot