Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sys.executable in command.run_command for version-independent execution. #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cpolish
Copy link

@cpolish cpolish commented Apr 7, 2023

One problem I found recently when trying to use Fildem on my Ubuntu 22.10 install, after installing Python 3.11 from apt and setting a symlink from python3.11 --> python3, was that when executing fildem, Python would raise a ModuleNotFoundError for fildem. This would happen even if I reinstalled Fildem explicitly using python3.10.

Having a look at the source code, I realised that this error most likely occurs due to the command being specified for the secondary Fildem thread in command.run_command using the python3 executable set in the system's PATH, which may not match the version of Python 3 used to install Fildem. To fix this, the code now replaces the call to python3 with sys.executable instead, which provides an absolute path to the Python 3 executable used at runtime.

Testing this on my system, this appears to have fixed the issue.

cpolish added 2 commits April 7, 2023 20:08
Make `command.run_command` use the executable recognised by the
Python interpreter (`sys.executable`) rather than the system `PATH`
`python3` executable. This prevents issues where the version of
Python 3 used to build and run Fildem may be different to the
Python 3 version pointed to by the system PATH, making Python not
be able to recognise the Fildem module installed with the original
Python version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant