Installing Panda3D in Ubuntu 24.04 LTS error: externally-managed-environment

So I Fire up a terminal on my fresh install of Ubuntu excited to get back to work.

As you know Panda3D is written in python, so we can install python packages using something called pip, then Panda3D:

    sudo apt update
    sudo apt install python3-pip
    pip install panda3d

This always worked for me in the past, but oddly now I get a weird error?

Screenshot from 2024-06-05 00-23-32

If we reference the Doc on the correct install procedure for Panda3D it says to use ‘RPM’ or ‘DEB’ ok so lets try deb (Debian packages for Ubuntu with ‘Apt’ installer)
Here are my results:

Screenshot from 2024-06-05 00-35-10

ok, so If you look in the pip error it says to use python3-xyz where xyz is our package, so let’s try that?:

Screenshot from 2024-06-05 00-36-38

my search for Panda3D deb package yeilds zero results:

I do see it as a PyPi package (when you do pip install):

After more googling I found out why, these are changes to Ubuntu policy,
so pip packages will not conflict with apt. If you want more info check out the article here:

3 Ways to Solve Pip Install Error on Ubuntu 23.04

This new barrier to entry was enough to turn me away from working today,
I’m going to bed! pouting and stomping my feet,
Packages in Ubuntu with flatpack and snap pack and apt its just all becoming a nightmare.

I’ll post my final solution when i’m less angry at the world! suggestion on updating the Doc is welcome, if anybody got it working. I’ll take a look again this weekend:

Official Panda3D install instructions Linux

1 Like

I hate the externally managed environments. Idk who came up with them, but that person needs a stern talking to. They’re kind of lying to you. Because they went full corpo and default to “uh, where’s your permit”.

For many, many, many python packages, particularly your own and particularly on your own home pc, it is absolutely no problem to use --break-system-packages and install them anyway.

I’m not sure if the --user flag will help before that, but it doesn’t hurt to try that first.

Anyway, it will only actually break anything if there is a conflict.

Why they went down the path to assume that the python environment you’re interacting with is in system space and you’re not allowed to touch it, instead of having a general user environment and you being allowed to mess around with that as much as you want, I don’t understand and I don’t know.

1 Like

Let me correct you, Panda3D is written in C++, it’s just that there are bindings in the .pyd format for the python programming language.

Using C++ in Panda3D

@serega-kkz yeah, you are right I just forgot about that.

There should be three ways to get Panda3D going.

  1. apt install (at time of writing not working)
  2. Install in a python virtual environment (recommended)
  3. Download and install directly (manual install)

The virtual install lets you PIP install any additional packages that you
want in a sort of sandbox. So you can have for example, one project
with one version of python modules and in another virtual env different versions of the same modules as needed for your project.

Let’s try installing Panda3D:

I tried ‘pip install virtualenv’ and get that same annoying error,
Then I tried 'apt install virtual env… and guess what that installed but
we are using python3 so that is no good, the correct command:

sudo apt install python3.12-venv

perfect! I’ve created a folder called ‘workspace’ and moved to it
and now I would like to create a virtual env

Screenshot from 2024-06-08 14-43-54

python3 -m venv shenko_env

when you do ‘ls’ you will notice a folder was created!

Now we want to ‘ACTIVATE’ our virtual Env!!!

in bash (terminal) you have a command called ‘source’
source command reads and executes the content of a file.

in the virtual env you created under the $youenv/bin folder is a file called ‘activate’ when you launch it using source you’ll notice your terminal prompt changes, you can shut it down by simply writting ‘deactivate’

in the future I want to make this easier,
a trick is to add a ‘alias’ to your bashrc file.
or I actually wrote a bash_alias file that has a bunch of custom commands.
bash alias example tutorial

(don’t forget to restart the terminal or exit and open new one for the alias to work)

the result is ‘activate’ turns it on ‘deactivate’ turns it off

Screenshot from 2024-06-08 15-13-56

I keep my ‘bash_aliases’ file on my dropbox, everytime
I do a new install or modify, I just have to do ‘tail bash_aliases’
which displays the last few lines in a file, where I added a line
that I can simply copy paste, it adds the ‘.’ making it hidden and puts it on the local machine.