简体   繁体   中英

ModuleNotFoundError: No module named 'winreg' on Mac? (But winreg is a windows thing)

I am receiving the following error when I try to run a django shell. I am on a Mac though and everything that I can find says that this is associated with Windows and that winreg should be installed by default. Suggestions as to what I should be looking at?

Traceback (most recent call last):
  File "/Users/j/code/myproject/core/manage.py", line 22, in <module>
    main()
  File "/Users/j/code/myproject/core/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/shell.py", line 127, in handle
    exec(sys.stdin.read(), globals())
  File "<string>", line 5, in <module>
ModuleNotFoundError: No module named 'winreg'

Between when I had a working env and the env producing the error I made a lot of changes to a script that I was working on including installing packages and adding modules.

When I tried to run the script I received the error above.

In the comments, Iain asked for the command I was running and then the contents of the script. Out of all the things I was looking at -- I ignored this, because was certain it was something I installed, not the file I was working on.

At the top of the file, I found this line in the imports:

from winreg import FlushKey

^^ My best guess is that this was accidentally added while I was quickly moving across the keyboard too quickly and I didn't noticed and pressed some sort of key combo that added it.

This is a first. 🫣

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM