I'm using Windows 10, Python 3.11.2, VS Code. When importing some of Python Standard Library modules, e.g.:
from collections import deque
I get the following error:
PS C:\Users\Karenin\Documents\IStudy> & C:/Users/Karenin/AppData/Local/Programs/Python/Python311/python.exe c:/Users/Karenin/Documents/IStudy/bt.py
Traceback (most recent call last):
File "c:\Users\Karenin\Documents\IStudy\bt.py", line 1, in <module>
from collections import deque
ValueError: source code string cannot contain null bytes
Pylint says:
Cannot import 'collections' due to 'invalid or missing encoding declaration for 'C:\\Users\\Karenin\\Documents\\IStudy\\collections.py''Pylint(E0001:syntax-error)
I got the same behavior when importing re:
import re
But this happens not for all modules. For instance, such modules as math, itertools, etc. are imported correctly. If I remove/comment the import string and the respective function call in the code, the rest works fine.
Default and current file encoding is set to UTF-8. I tried running the same code in PyCharm. Tried reinstalling Python 3.11.2, using Python 3.10.10. Nothing works. However, the same imports do work correctly in Python REPL. Any ideas of how can I fix it?
you place check mark in install pip ?