I have a Python 2 script that I'm trying to run within the latest Python docker container. That container supports Python 3, and I thought could manually adapt the script. My manual adaptations worked just fine... except for this:
The original Python 2 script contained this line:
from multiprocessing import Queue, Manager, Lock
But thanks to post like this and this, I know that "Queue" isn't a Python 3 module; the module I need is "queue". So I changed my code to this:
import queue
from multiprocessing import Manager, Lock
When I spin up my container then run the script (within the container), I get this:
Traceback (most recent call last):
File "/usr/local/bin/myscript", line 4, in <module>
__import__('pkg_resources').run_script('myscript==0.1.0', 'myscript')
File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 651, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1455, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python3.9/site-packages/myscript-0.1.0-py3.9.egg/EGG-INFO/scripts/myscript", line 21, in <module>
File "<frozen zipimport>", line 259, in load_module
File "/usr/local/lib/python3.9/site-packages/myscript-0.1.0-py3.9.egg/openbmp/myscript/logger.py", line 15, in <module>
ModuleNotFoundError: No module named 'Queue'
The above makes little sense to me; here's the referenced part of the script, with line numbers included:
15 import sys
16 import signal
17 #from multiprocessing import queue, Manager, Lock
18 import queue
19 from multiprocessing import Manager, Lock
20
21 from myscript.logger import LoggerThread
Ugh. The Docker container is adding as extra layer of complexity and I don't understand what's going on.
More experienced programmers: Is there a suitable fix here? Or should I just give up and use the Python 2 Docker container? Thank you.