Hey smart people of the Internet. It seems like things have changed (for the worse) in newer #Python. I am trying to install #wxPython like I always have been doing, per https://wxpython.org/pages/downloads/

pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-24.04 wxPython

And it is suddenly yelling at me to not install the exact way I have been installing this for years and years. What is the new cool hip way they want me to do this? Preferably uncomplicated. #ubuntu #gnu #linux #programming

wxPython Downloads

Current Release Starting with wxPython 4.0 (the first Phoenix release) the wxPython source archive and, for supported platforms, wxPython binary wheels are available from the Python Package Index (PyP

wxPython
@RomanOnARiver
What's the output from that pip command?
@dragon0 thanks for responding. The error is "externally-managed-environment" asks me to use apt which wouldn't get me the latest version I want

@RomanOnARiver
Then it's like @diazona said, the "hip" way is to use a virtual environment.

You can use `python -m venv` to create one, but you might want to take the opportunity to learn one of the project-oriented tools like PDM or Poetry. Then it's just a simple `pdm add wxpython` or `poetry add wxpython`.

An advantage of these tools is they'll record the exact versions of all packages they install, so when you return to the project it'll still work exactly as you left it.

@dragon0 @diazona so if I'm installing some module in a virtual environment is it accessible from any python script on the system or do I need to run python from inside that virtual environment?

@RomanOnARiver @dragon0 You need to run the python from that virtual environment. (There are a few packages that are written to allow them to use things from other virtual environments, but that's quite rare.)

But note that if you have a Python script (a .py file) sitting somewhere on your system, that script doesn't inherently belong to any virtual environment. It's the Python *interpreter*, and installed packages, that belong to virtual environments. If you just have a script file, you can use an interpreter from any virtual environment to run it. It may do different things depending on which interpreter you use. (Like, usually, failing with an error if the script uses some package that isn't installed in that particular virtual environment.)

#Python

@diazona @dragon0 gotcha, so if my virtual is in /foo/bar/python as opposed to my global /bin/python or wherever they put it, I'm running /foo/bar/python and my script can be anywhere, if I'm understanding correctly.

@RomanOnARiver @dragon0 Yes, exactly. You would run `/foo/bar/python script.py`.

Note that if you're working on Linux or similar, it would be unusual to create a virtual environment somewhere you needed to use `sudo` for it - like /foo - unless you're specifically installing something meant to be used system-wide. (Not very common.) Virtual environments are lightweight, they're meant to be created and deleted over and over again as needed, so it's not like you have to put them somewhere "permanent".

#Python

@diazona @dragon0 oh yeah okay I gotcha that makes sense. If I do want it in a folder I'm assuming it stays there until I get rid of it? Does it survive day distro upgrades? One issue I had with the old (wrong) way I had been using is every distro upgrade would wipe away all those external modules.

@RomanOnARiver @dragon0 Yep it survives upgrades! The virtual environment, once created, is basically just a bunch of files, and like any other files, they won't be touched during a distro upgrade (unless you put the files somewhere they conflict with something on the system, but that's why you should put them under your home directory 😛 )

There is one catch though, which is that the virtual environment doesn't actually contain a whole independent copy of Python, at least not on Linux - it contains a symlink pointing back to the Python that created it. That can cause some trouble. For example, if you had Python 3.10 as the default on your system (like in Ubuntu 22.04) and you ran `python3 -m venv mypath`, then you later upgrade to Ubuntu 24.04 which doesn't have Python 3.10, the virtual env in `mypath` would stop working because it'd be looking for Python 3.10 that is not there. (But you can delete `mypath` and create a new venv.)

#Python