Problem running a PyQt5 project in WSLg - no application window shows up - pyqt5

I am running WSL2 under Windows 10.
If I type "gedit &" into the WSL console, the Gedit application window pops up. Thus I assume that WSLg properly works.
Next, I am trying to run the following PyQt5 project:
https://github.com/rafaelpadilla/review_object_detection_metrics
However, no application window pops up this time, although no error message appears either.
First of all, I do wonder whether this could work at all with WSL!?
Appendix for additional context:
I am not using conda because of licensing issues, but a combination of pyenv + poetry instead. First I had problems with a missing library (libxcb.so), which I could solve by running "sudo apt python-pyqt5". Now everything seems to work, except from no application window being shown.
UPDATE:
I tried with "/src/pyqt-official/qtdemo/qtdemo.py" from the official PyQt Examples github repository and I observed exactly the same issue.
There is no error message. Last prompt informs me that the "xcb plugin was loaded“, then nothing happens. In particular, no window is showing up.
Some related observations:
(1) I haven't yet updated my grafics card driver to support vGPUs. However, Gedit works and opens in a separate window.
(2) Unless I do "sudo apt install python3-pyqt", I receive an error message saying that it cannot find "libxcb.so". However, I am running the code in a virtual pyenv/poetry environment, which is separate from the system python installation. I don't understand why "sudo apt install python3-pyqt" makes a difference here. Shouldn't installing "PyQt5" with poetry obtain a wheel that comes with all libraries already compiled? I don't understand how all of this is playing together.
Open Questions:
Do you think the driver issue could be an explanation? I actually cannot imagine that. I thought it is only about better performance for OpenGL applications.
Can you explain observation (2)?
What else can I do?

First of all, I do wonder whether this could work at all with WSL!?
I can't tell you if that particular application will run under WSL, but my expectation is that it will. As far as I can tell in its dependencies there doesn't seem to be any reliance on GPU compute. That, to me, would be the trickiest part to configure under WSL (but is still typically possible). However, there may be other dependencies (not covered below) that you need to get running before the application can work.
What I can confirm is that PyQt works under WSL just fine. However, keep in mind that a default Ubuntu installation under WSL is based on a non-GUI Ubuntu Server distribution, rather than standard Ubuntu (with a desktop and GUI).
This means that Ubuntu Server is often missing system level libraries needed for GUI support, which appears to be the case here.
I don't understand why "sudo apt install python3-pyqt" makes a difference here. Shouldn't installing "PyQt5" with poetry obtain a wheel that comes with all libraries already compiled?
Poetry and/or Pip manage the Python library dependencies, but those Python libraries still require the native system library dependencies. That's where sudo apt install python3-pyqt5 comes in. Under a desktop Ubuntu system, most of these libraries would already be in place. However, with Ubuntu Server/WSL, they aren't.
For reference, here's my configuration. On a freshly initialized Ubuntu 22.04 WSL2 distribution:
sudo apt update && sudo apt upgrade -y
sudo apt install python3-venv python3-pyqt5
mkdir -p src/pyqt_test
cd src/pyqt_test
python3 -m venv .venv
source .venv/bin/activate
pip install pyqt5
I was then able to create and run the following, taken from Learn Python PyQt:
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
windows = QtWidgets.QWidget()
windows.resize(500,500)
windows.move(100,100)
windows.show()
sys.exit(app.exec_())
The window displayed correctly.

Related

anaconda installing numpy/pandas/matplotlib error

first post here, so I'm going to try to be as thorough as possible.
I'm trying to install numpy/matplotlib/pandas for a project. First time trying to use them. I'm following the steps of a tutorial, so I can't vary from that too much (have to use anaconda). I'm using mac OS Sierra 10.12.5
What I've done:
installed python 3, anaconda, and create and initialize a virtual environment using Anaconda. I then type:
conda install numpy pandas matplotlib
The terminal then tells me what new packages will be installed, I proceed. A few are installed successfully, and then I get this error:
CondaError: CondaHTTPError: HTTP None None for url https://repo.continuum.io/pkgs/free/osx-64/mkl-2017.0.3-0.tar.bz2
Elapsed: None
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
I thought this might be a connection issue, as I'm in China, but I've tried multiple times both using and not using a VPN. This problem is really stopping me in my tracks, any ideas?
Have you tried using the pip installer, or installing using the Anaconda navigator? To install using pip, after creating the virtual environment, open a terminal console, and type
source activate [name of virtual environment]
pip install numpy
pip install matplotlib
pip install pandas
Pip is included in the base anaconda installation, so this should work. If your Anaconda installation included the Anaconda Navigator, you can also install these modules through the GUI, by opening the Anaconda Navigator, clicking on the environments tab, selecting the virtual environment, searching for module in the search bar (make sure you select All and not Installed in the dropdown menu next to it), and then selecting the desired modules and clicking the apply button (this is an example).

Gnuradio companion not installed after running build-gnuradio script

I tried installing Gnuradio 3.7.9.2 using build-gnuradio script and apart from a few hiccups due to some packages (which I installed and re-ran the script again) , the script completed its run successfully (I enabled the verbose option of the script to check the output). I even added the PYTHONPATH to the .bashrc script after completing the installation. When I tried launching gnuradio-companion though, it doesnt recognise the command.
:~$ gnuradio-companion
The program 'gnuradio-companion' is currently not installed. You can install it by typing:
sudo apt-get install gnuradio
So, I was wondering whether I need to install grc separately after the build-gnuradio script installation ?. I apologise if this is too simple, I have tried the installation many times and searched the web for problems like this. To the best of my efforts, I was not able to find any. It would be great, if anyone can point to any existing question similar to this, or guide me in fixing this issue. Thank you.
It is advised to use PyBOMBS to install GNU Radio. Installing Out-of-Tree modules (OOTs) will be much easier afterwards. As for your problem: Did you check if your $PATH variable (echo $PATH) contains /usr/local/bin/? This should be the default installation path for a non-system install of GNU Radio.
Alternatively you can try to run /usr/local/bin/gnuradio-companion.

PyCharm and external libraries

I have started to use PyCharm IDE, but I was not able to determine how to manage external libraries there. For instance, PyCharm does not see matplotlib. In PyCharm's file manager, I clearly see the list of external libraries and there is no matplotlib. However, I have it installed and I know its location.
How can I add this library to PyCharm environment?
I suggest to use Python virtual environment. It is really easy with PyCharm.
PyCharm > Preferences... > Project Interpreter > Python Interpreters
Click "Create Virtual Environment" and pick your base interpreter.
Click "Install" and install any packages you need. You can also add other repositories if the default ones do not contain required libraries. Another benefit is that you can see which libraries have newer version and can be updated.
I think one way to solve a problem is to specify your interpreter in PyCharm itself via File -> Settings -> Python Interpreters
There is also a Paths tab in this setting, you need to add path to your matplotlib explicitly there. But for me there is no special path listed there. Here are my paths in this tab:
file://D:/hg_work/vefw_regression/tools/python/DLLs
file://D:/hg_work/vefw_regression/tools/python/Lib
file://D:/hg_work/vefw_regression/tools/python/Lib/lib-tk
file://D:/hg_work/vefw_regression/tools/python
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages (my matplotlib/numpy and other stuff is here)
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/win32
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/win32/lib
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/pythonwin
file://D:/Users/svecovs/AppData/Roaming/JetBrains/PyCharm Community Edition 3.0.1/helpers/python-skeletons
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/core (added by user)
Install matplotlib and then python-tk.Pycharm will function well.It's working for me at Ubuntu 16.04.
sudo apt-get install python-tk
sudo apt-get install python-matplotlib
For Linux Users here is a solution ,
firstly write this command in the terminal ,
sudo apt-get install python-matplotlib
Now you're done you will be able to see matplotlib in File>>>settings>>project interpreter.
Image
Solve this problem by choosing system interpretator.

How to install recent mono and monodevelop?

I tried to install mono and monodevelop on centOS 6.3.
After many hours I was able to install mono but failed with monodevelop.
I'm really astonished how difficult and time consuming it is, to get a recent mono/monodevelop version on linux installed.
Is there nobody willing to write and maintain an install/compile tutorial to get the most recent mono/monodevelop/monodata/ASP.NET MVC/... version on the major linux distributions (Centos, Ubuntu, Suse, Debian) installed?
I think many people developing on Windows (with limited linux knowledge) would like to start using mono, if the boarding hurdle would be somehow lower.
It may be the most important to make Mono more used and more visible.
Please, write a tested tutorial (script) for compiling mono/monodevelop.
Thank you!
I have created a project on Open Build Service, which produces builds of the latest MonoDevelop 4.0.10 for Debian, Ubuntu, CentOS, and Fedora.
see https://build.opensuse.org/project/show/home:tpokorra:mono
For installation instructions with apt-get or yum, see:
http://software.opensuse.org/download/package?project=home:tpokorra:mono&package=monodevelop-opt
I hope this will increase the usage of MonoDevelop on Linux Desktop environments.
Monodevelop 4.
If you use any *buntu. Check this.
"You can open up the terminal and install it via the following:
1. sudo add-apt-repository ppa:keks9n/monodevelop-latest
2. sudo apt-get update
3. sudo apt-get install monodevelop-latest"
http://mono-d.alexanderbothe.com/?p=101
Xamarin should be doing a better job at publishing the linux packages in a one-click manner. I don't care what linux distro (SuSE, RHEL, CentOS, Ubuntu etc) - just pick any one as the supported one and publish for it. It seemed that it used to be SuSE but even that has old packages as seen within Zypper/YaST.
Update Mono framework
Having said that, to update the Mono framework itself, without letting go of the package managers try this. This will work as long as the project dutifully publishes the RPMs. You don't want to build from source since it's a more fickle process and the setup distracts from your real objective (i.e. develop).
Obviously, please replace the URL below to what will be latest by the time you're reading this.
mkdir mono-rpms
cd mono-rpms
wget --reject "index.html*" -nd -r -e robots=off --no-parent http://download.mono-project.com/archive/3.2.3/linux/x64/
sudo zypper install *rpm
Update MonoDevelop (the IDE)
Timotheus Pokorra's answer indicates he's filling in some of the usability void left by Xamarin (Thanks Timotheus!!). You can install MonoDevelop via
http://software.opensuse.org/download/package?project=home:tpokorra:mono&package=monodevelop-opt
Note that on SuSE I get the error
Problem: nothing provides liberation-mono-fonts needed by mono-libgdiplus-opt-3.0.12-7.1.x86_64
Solution 1: do not install monodevelop-opt-4.0.12-5.2.x86_64
Solution 2: break mono-libgdiplus-opt-3.0.12-7.1.x86_64 by ignoring some of its dependencies
I (very reluctantly) selected to break the dependency. Note that I already had liberation-fonts (via sudo zypper install liberation-fonts). I don't know if its the same/different as liberation-mono-fonts. Anyway, hope Timotheus fixes it when he has a moment.
I'm not sure if you've already seen this, but this may help:
http://www.mono-project.com/Parallel_Mono_Environments
The most common problem that new developers have when coming to Linux from systems like Windows is not properly setting up their environment variables and so when they do the standard ./configure && make && make install routine, when it involves a number of source packages (like Mono does), any package that depends on the core package won't pick up the correct location for that base package.
Your question really doesn't explain what parts you found confusing or difficult so it's hard to address those issues.
For people unfamiliar with setting up Linux systems, it may be easier if you just go with a system like Ubuntu which has fairly recent pre-built packages (although not the latest - I don't think any Linux system keeps up with Mono releases) rather than wrestling with the learning curve of how to build everything yourself.
It is confirmed that in the near future Xamarin will support Linux and provide binaries (mono and mainline applications) for Debian and Centos derivatives, and their are already packages for Debian and Centos derivatives for technical preview. So cheers and no more pain of compiling and even parallel mono installaions.It can not get more easy than this. Check here

How to install OpenNI 1.x on a Mac?

I have a Kinect for Windows and I would like to connect it to my Mac laptop with OSX 10.7.5.
I would like to use openNI as the driver.
OpenNI's website lists "OpenNI 2.1 Beta (OS X)" however the source-code page does not list install instructions. Are they found someplace else?
There are install instructions on the OpenNI 1.x github page and on OpenNI 1.x Unstable branch page. The instructions for the two branches are slightly different, however neither have worked for me.
I originally had XCode 4.6 installed. Both instructions state they want XCode 4.3.2, which I installed, renamed XCode 4.6 and used "sudo xcode-select -switch" to switch between them.
Both instructions ask for "libusb-devel +universal" and in both cases I get:
Error: Please do not install this port since it has been replaced by 'libusb'.
Error: org.macports.configure for port libusb-devel returned:
Please see the log file for port libusb-devel for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_libusb-devel/libusb-devel/main.log
Error: Processing of port libusb-devel failed
If I continue with the installation of "libusb +universal" instead, then the rest of the dependencies install fine (though I had to install GraphViz before Doxygen).
But then when I run: "./RedistMaker" I get a lot of warnings, though it does create a Final file. "sudo ./install.sh" runs fine and I'm guessing OpenNI is installed, but then I get a bunch more errors when trying to install Sensor.
Can anyone help tell where along the way should I have started to worry? Do I need to manually install libusb (which I have tried to do)?
Any help appreciated!
I fixed the installation of OpenNI by running these instructions:
> sudo rm -f /opt/local/lib/libusb-1.0.0.dylib
> sudo port clean libusb
> sudo port install libusb +universal
Basically the Mac install instructions need to be updated and should include a warning that the short install may leave files around that will need to be deleted before installing with port.