Python Using PySide6

Documentation for working with Python on FreeBSD is a tad thin on the ground and I'm baffled. I had assumed that all OSs handled Python and its libraries the same way... install libraries using pip, set up virtual environments using venv... and that a Python script written on Windows 10 (what I'm used to) would just run on FreeBSD if I had the correct libraries installed (in this case, PySide6) by pip.

Enough backstory.

I found and installed pyenv, but again, no mention of FreeBSD in its docs. Their passing mention of UNIX as part of the Mac instructions just seems like a red herring. And I have no idea if I'm using it correctly. I used it to install Python 3.11.10, but that's a far as I got. Does it just work once installed (with shims) or do I need to invoke it the way venv is invoked?

I found the package for py311-pyside6 and installed that using pkg, but there's something missing because when I run a Python script that imports PySide6 modules, it says there are no such modules. Is this a PATH issue or (as suggested by the chat bots) a PYTHONPATH issue? BTW, I noticed that there is no default PYTHONPATH, at least not on my machine. Does this package just contain pyside libraries or the bindings as well? Or does FreeBSD take a completely different approach to interfacing to PySide6 from Python?

If anyone can shed light on how to:
- set up a Python development environment with virtual machines,
- install and configure Python libraries so the scripts I'm running can find them, and
- share any information about how to use pyenv on FreeBSD...

I'd be ever so grateful.
 
I found the package for py311-pyside6 and installed that using pkg, but there's something missing because when I run a Python script that imports PySide6 modules, it says there are no such modules.
What exactly is the problem?

Code:
dice@fbsd-test:~ % python3.11
Python 3.11.10 (main, Oct  8 2024, 01:06:24) [Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15 on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySide6.QtCore
>>>
>>> # Prints PySide6 version
>>> print(PySide6.__version__)
6.7.3
>>> # Prints the Qt version used to compile PySide6
>>> print(PySide6.QtCore.__version__)
6.7.3
Seems to work just fine, only installed devel/pyside6.
 
What exactly is the problem?
When I run a python script, I get this error (forgive any typos; I haven't got the shared clipboard working on VirtualBox):
Code:
Traceback (most recent call last):
  File "/home/ron/pyside/01_window/ui_main_window.py", line 1, in <module>
    from PySide6 import QtCore, QtGui, QtWidgets
ModuleNotFoundError: No module name 'PySide6'
Code:
dice@fbsd-test:~ % python3.11
Python 3.11.10 (main, Oct  8 2024, 01:06:24) [Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15 on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySide6.QtCore
>>>
>>> # Prints PySide6 version
>>> print(PySide6.__version__)
6.7.3
>>> # Prints the Qt version used to compile PySide6
>>> print(PySide6.QtCore.__version__)
6.7.3
Seems to work just fine, only installed devel/pyside6.
I get the same error (cited above) using IDLE, too.

All I can think of is that I've missed something during installation, some extra package... or perhaps installed something wrong. If neither of you have any ideas, since it's just in VirtualBox ATM, I'll scrape it clean and start over, documenting my steps as I go this time.
 
Traceback (most recent call last):
File "/home/ron/pyside/01_window/ui_main_window.py", line 1, in <module>
Is this inside a venv? Or perhaps it runs with a different Python version? The py311-pyside6 package is for Python 3.11 (you can tell by the py311 prefix).

Code:
dice@fbsd-test:~ % python3.11
Python 3.11.10 (main, Oct  8 2024, 01:06:24) [Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15 on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide6 import QtCore, QtGui, QtWidgets
>>>
No errors on that import.
 
Back
Top