Search code examples
pythonshellgodotpython-venvgodot4

Godot 4 cannot run Python Script, permission denied


I'm basically building a GUI app in Godot 4. Initially, the problem was to not be able to import numpy into a venv in the Godot project folder. The problem is explained here.

The follow-up to this problem, is that the one script cannot be executed. After pressing a button in Godot, two scripts are executed. The first scripts works without a problem, whereas the second script throws an error message.

Both Scripts work the same. They are called with:

OS.execute(python_interpreter, [python_script_path_not, title, body, icon])

(This one works) or with:

var arguments = [some, values, here, and, there]
var exit_code = OS.execute(python_interpreter, arguments, output, true)

(This one doesn't work)

Both files can be easily executed from the terminal, after cd"ing" into the same folder used by Godot. After activating the venv, both scripts can be called without a problem.

The error message given by Godot looks like this:

["Traceback (most recent call last):\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/psutil/_pslinux.py\", line 1653, in wrapper\n
    return fun(self, *args, **kwargs)\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/psutil/_pslinux.py\", line 2121, in cpu_affinity_set\n
    cext.proc_cpu_affinity_set(self.pid, cpus)\n
PermissionError: [Errno 1] Operation not permitted\n
\n
During handling of the above exception, another exception occurred:\n
\n
Traceback (most recent call last):\n
  File \"/home/user/Desktop/PythonFiles2/vimuscript.py\", line 176, in <module>\n
    main()\n
  File \"/home/user/Desktop/PythonFiles2/vimuscript.py\", line 52, in main\n
    app(args.pcap_file, args.decode_tunnels, args.bpf_filter, args.snapshot_length, args.idle_timeout, args.active_timeout, args.accounting_mode, args.n_dissections, args.statistical_analysis, args.splt_analysis, args.n_meters, args.export_format, args.download_filepath)\n
  File \"/home/user/Desktop/PythonFiles2/vimuscript.py\", line 105, in app\n
    pandas = streamer.to_pandas()\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/nfstream/streamer.py\", line 545, in to_pandas\n    total_flows = self.to_csv(path=temp_file_path, columns_to_anonymize=columns_to_anonymize, flows_per_file=0)\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/nfstream/streamer.py\", line 517, in to_csv\n
    for flow in self:\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/nfstream/streamer.py\", line 367, in __iter__\n
    set_affinity(0)  # we pin streamer to core 0 as it\'s the less intensive task and several services runs\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/nfstream/utils.py\", line 156, in set_affinity\n
    psutil.Process().cpu_affinity(list(temp[idx % x]))\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/psutil/__init__.py\", line 830, in cpu_affinity\n
    self._proc.cpu_affinity_set(list(set(cpus)))\n
  File \"/home/user/Desktop/PythonFiles2/venv/lib/python3.10/site-packages/psutil/_pslinux.py\", line 1655, in wrapper\n
    raise AccessDenied(self.pid, self._name)\n
psutil.AccessDenied: (pid=76525)\n
"]

I am not quite sure, but looks like the key problem is Godot somehow not having the right access. Assuming the Access really is the only problem, how could this problem be resolved after exporting this project to another OS, or device,

Ubuntu Version 22.04 (also tried on Mac-OS 13.xx) Python Version 3.10 Godot Version 4.1.1


Solution

  • Turns out, this problem was solved after updating Godot 4.1.1 to 4.1.2. I still cannot fully explain what caused the problem in the first place, but it got fixed in the update.