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

Qudi modifies system path variable #12

Closed
Geegee opened this issue Feb 7, 2022 · 7 comments
Closed

Qudi modifies system path variable #12

Geegee opened this issue Feb 7, 2022 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@Geegee
Copy link
Contributor

Geegee commented Feb 7, 2022

Version

v1.0.1

What is affected by the bug?

I tried using different versions of Pyside2 5.15.2.1 / 5.15.2 / 5.15.1 to no avail.
Just running pyside2-uic "some-gui-module.ui" runs without error.
As @kay-jahnke pointed out it seems like the environment qudi runs in
does not have access to "pyside2-uic".
Yet in the same terminal qudi is started from and in the same environment pyside2-uic can
be run from the command line.

This shows the output when run sys.path within qudi:
image
The output where pyside2-uic resides
image
This is when run in the ipython console
image
It seems like qudi is modifying the path variable, which I am not sure how to fix at the moment.

When does the bug occur?

Trying to load Gui modules with a "*.ui" file.

How do we replicate the issue?

Seems to occur only on Linux.

Expected behavior

Create a uic file.

Relevant log output

Exception during activation:

FileNotFoundError: [Errno 2] No such file or directory: 'pyside2-uic "/tmp/tmp57zk2x42"'
Traceback (most recent call last):

  File "/home/geegee/Documents/Programme/qudi-core/src/qudi/core/module.py", line 286, in __activation_callback
    self.on_activate()

  File "/home/geegee/Documents/Programme/qudi-iqo-modules/src/qudi/gui/time_series/time_series_gui.py", line 115, in on_activate
    self._mw = TimeSeriesMainWindow()

  File "/home/geegee/Documents/Programme/qudi-iqo-modules/src/qudi/gui/time_series/time_series_gui.py", line 45, in __init__
    loadUi(ui_file, self)

  File "/home/geegee/Documents/Programme/qudi-core/src/qudi/util/uic.py", line 70, in loadUi
    result = subprocess.run(f'pyside2-uic "{file_path}"',

  File "/usr/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:

Additional Comments

No response

Contact Details

wgolff@googlemail.com

@Geegee Geegee added the help wanted Extra attention is needed label Feb 7, 2022
@drogenlied
Copy link
Member

drogenlied commented Feb 7, 2022

You did not show the actual error here, can you post that?
Where do you get your Python from? System Python or Miniconda?

@Neverhorst
Copy link
Member

The only place where the path could differ from the qudi process is here
I think subprocess.run can be configured accordingly. That's the place where I would start searching for the bug.

@Geegee
Copy link
Contributor Author

Geegee commented Feb 7, 2022 via email

@drogenlied
Copy link
Member

drogenlied commented Feb 7, 2022

Python sys.path is not really $PATH.

jan@janvision:~$ echo $PATH
/home/jan/.local/bin:/home/jan/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
jan@janvision:~$ python3
Python 3.9.10 (main, Jan 16 2022, 17:12:18) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/jan/.local/lib/python3.9/site-packages', '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages']
>>> 

We should also switch back to QtUiTools.loadUiType() instead of implementing UI compilation ourselves.

see https://bugreports.qt.io/browse/PYSIDE-1223

@Neverhorst
Copy link
Member

We should also switch back to QtUiTools.loadUiType() instead of implementing UI compilation ourselves.

see https://bugreports.qt.io/browse/PYSIDE-1223

Gladly... if this works now. My last attempt was over a year ago.
This ugly workaround is not nice but I did not see another way back then.

A problem that will still remain however is having custom/promoted widgets in the .ui file. Resource management is a bit of a pain in Qt with Python. E.g. making these .ui files work when people can install qudi (addon-)packages anywhere on their system.

@Geegee
Copy link
Contributor Author

Geegee commented Feb 7, 2022

After trying commands like 'ls' etc. which also did not work I figured out that the path could not really be the cause
of these problems.
If I use:
result = subprocess.run(["pyside2-uic", f"{file_path}"], capture_output=True, text=True, check=True)
the GUI modules start without a problem. Why is the other syntax not working here? Is it maybe only working
for stdin?

The question is now if this change would break something on other platforms
like windows?

Another thing which works is
result = subprocess.run("pyside2-uic '{}'".format(file_path), capture_output=True, text=True, check=True, shell=True)

@Neverhorst
Copy link
Member

Has been resolved by merging PR #18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants