我想为 python 2.7 创建一个 virtualenv (我使用的是 3.7)
我以管理员身份运行 cmd(在 Windows 10 上):
C:\WINDOWS\system32>virtualenv -p C:\Python27\python.exe py27
我收到错误:
Running virtualenv with interpreter C:\Python27\python.exe
Traceback (most recent call last):
File "c:\path\to\virtualenv.py", line 26, in <module>
import logging
File "C:\Python27\lib\logging\__init__.py", line 43, in <module>
import threading
File "C:\Python27\lib\threading.py", line 15, in <module>
from collections import deque
File "C:\Python27\lib\collections\__init__.py", line 55
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
^
SyntaxError: invalid syntax
当我启动 Python2.7 并尝试导入日志记录模块时:它显示相同的错误,但当我重新输入它时。它工作得很好:
>>> import logging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\logging\__init__.py", line 43, in <module>
import threading
File "C:\Python27\lib\threading.py", line 15, in <module>
from collections import deque
File "C:\Python27\lib\collections\__init__.py", line 55
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
^
SyntaxError: invalid syntax
>>> import logging
>>> logging.warning('hello word')
WARNING:root:hello word
>>>
我不明白为什么它会这样做。
我已经使用 python 3.6 配置了虚拟环境
任何帮助,将不胜感激。