Re: Debian 12: errors when using Python3 venv?
Hello On 15.6.2023 7.03, Kushal Kumaran wrote: On Wed, Jun 14 2023 at 03:55:44 PM, Nicholas Papadonis wrote: Hi, I just cleanly installed Debian 11 and am trying to create a virtual environment for Python. I get the following error, does anyone know how to resolve this? Am I missing some packages that need to be installed? 1843 [deb12:~]$ python3 -m venv pt Traceback (most recent call last): File "", line 189, in _run_module_as_main File "", line 148, in _get_module_details File "", line 112, in _get_module_details File "/usr/lib/python3.11/venv/__init__.py", line 7, in import logging File "/usr/lib/python3.11/logging/__init__.py", line 43, in import threading File "/home/vboxuser/threading.py", line 3, in sem = threading.Semaphore() ^^^ AttributeError: partially initialized module 'threading' has no attribute 'Semaphore' (most likely due to a circular import) Your /home/vboxuser/threading.py is hiding the threading module from the python standard library. Python is loading the first file with .py extension as module when it is requested by an import in the called script. Even an empty file is loaded as module. The feature or bad thing is that the current directory is in the python path. $ touch threading.py $ python -m venv my_venv Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/usr/lib/python3.10/runpy.py", line 146, in _get_module_details return _get_module_details(pkg_main_name, error) File "/usr/lib/python3.10/runpy.py", line 110, in _get_module_details __import__(pkg_name) File "/usr/lib/python3.10/venv/__init__.py", line 7, in import logging File "/usr/lib/python3.10/logging/__init__.py", line 217, in _lock = threading.RLock() AttributeError: module 'threading' has no attribute 'RLock' Error in sys.excepthook: BR, Roland
Re: Debian 12: errors when using Python3 venv?
On Wed, Jun 14 2023 at 03:55:44 PM, Nicholas Papadonis wrote: > Hi, > > I just cleanly installed Debian 11 and am trying to create a virtual > environment for Python. > > I get the following error, does anyone know how to resolve this? Am I > missing some packages that need to be installed? > > 1843 [deb12:~]$ python3 -m venv pt > Traceback (most recent call last): > File "", line 189, in _run_module_as_main > File "", line 148, in _get_module_details > File "", line 112, in _get_module_details > File "/usr/lib/python3.11/venv/__init__.py", line 7, in > import logging > File "/usr/lib/python3.11/logging/__init__.py", line 43, in > import threading > File "/home/vboxuser/threading.py", line 3, in > sem = threading.Semaphore() > ^^^ > AttributeError: partially initialized module 'threading' has no attribute > 'Semaphore' (most likely due to a circular import) Your /home/vboxuser/threading.py is hiding the threading module from the python standard library. -- regards, kushal
Re: Debian 12: errors when using Python3 venv?
Am Wed, Jun 14, 2023 at 03:55:44PM -0400 schrieb Nicholas Papadonis: > File "/home/vboxuser/threading.py", line 3, in I'm surprised about this file. It should not appear by creating a python venv. Best regards Ulf
Re: Debian 12: errors when using Python3 venv?
Hey there, On Wed, Jun 14, 2023 at 3:56 PM Nicholas Papadonis < nick.papadonis...@gmail.com> wrote: > I just cleanly installed Debian 11 and am trying to create a virtual > environment for Python. > Assuming you meant Debian 12 here, based on the subject line, and am answering as such. > I get the following error, does anyone know how to resolve this? Am I > missing some packages that need to be installed? > > 1843 [deb12:~]$ python3 -m venv pt > First time I ran this I was notified that I didn't have the python3-venv package installed. After taking care of that, I was able to run your command without any errors on my clean Debian 12 system. Traceback (most recent call last): > File "", line 189, in _run_module_as_main > File "", line 148, in _get_module_details > File "", line 112, in _get_module_details > File "/usr/lib/python3.11/venv/__init__.py", line 7, in > import logging > File "/usr/lib/python3.11/logging/__init__.py", line 43, in > import threading > File "/home/vboxuser/threading.py", line 3, in > sem = threading.Semaphore() > ^^^ > AttributeError: partially initialized module 'threading' has no attribute > 'Semaphore' (most likely due to a circular import) > This won't be helpful information for you in that I am not providing a solution, but please know that I couldn't reproduce your issue on my system so I suspect there is something amiss with yours. I hope this is something of a pointer for you. David