简体   繁体   中英

Can't import anything in Python3.7 after Windows 10 Update

I'm now facing this problem. I thought it was my software problem but I could not find the bug. Then I opened a console and tried:

>>> import requests

Traceback (most recent call last): ...
  File "<frozen importlib._bootstrap>", line 980, in _find_and_load
  File "<frozen importlib._bootstrap>", line 148, in __enter__
  File "<frozen importlib._bootstrap>", line 174, in _get_module_lock
  File "<frozen importlib._bootstrap>", line 60, in __init__
RuntimeError: can't allocate lock

I tried to import other stuff as well, and I got:

>>> import keyboard
Traceback (most recent call last):
"C:\Users\Lincoln\AppData\Local\Programs\Python\Python37\lib\threading.py", line 8, in <module>    
    from traceback import format_exc as _format_exc    
MemoryError

Pip seems not working as well:

C:\Users\Administrator>pip
Traceback (most recent call last): ...
"C:\Users\Lincoln\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_vendor\requests\compat.py", line 64, in <module>
    from http import cookiejar as cookielib
MemoryError

I'm really confused. They worked fine before.

Using: Python3.7, pip 18.0, Windows 10.

Tried: Restart my computer, reinstall python and run python as administrator but they didn't work.

I've just installed a Windows Update (KB4464218)

The question was caused by Windows 10 Exploit Protection.

I went to Windows Defender -> App & Browser Control -> Exploit Protection -> Program Settings and added a custom rule (by path) and turn off all protections for python.

I will be happy to accept better solutions.

1) Uninstall Python

2) Lookup for "Python" in folders on your PC

3) Delete all finded folder with name "Python"

4) Install again Python

If not helped, repeat 1-3 and install Python 3.6.

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