Python“;“随机导入”;生成";导入错误:无法导入名称';方法类型'&引用;
我正在使用Python“;“随机导入”;生成";导入错误:无法导入名称';方法类型'&引用;,python,visual-studio,Python,Visual Studio,我正在使用 Visual Studio 2017 Python 3.6 64位 当我使用VisualStudio构建的交互环境时,我将“导入随机”没有问题 当我运行代码(没有调试器)时,我得到以下错误 Traceback (most recent call last): File "C:\Users\Andy Slater\github\Introduction to Python Fundamentals\Introduction to Python Fundamentals\sort
- Visual Studio 2017
- Python 3.6 64位
Traceback (most recent call last):
File "C:\Users\Andy Slater\github\Introduction to Python Fundamentals\Introduction to Python Fundamentals\sorting.py", line 149, in <module>
import random
File "C:\Program Files\Python36\lib\random.py", line 41, in <module>
from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType
ImportError: cannot import name 'MethodType'
回溯(最近一次呼叫最后一次):
文件“C:\Users\Andy Slater\github\Python Fundamentals简介\Python Fundamentals简介\sorting.py”,第149行,在
随机输入
文件“C:\Program Files\Python36\lib\random.py”,第41行,在
从类型导入MethodType为_MethodType,从内置MethodType为_内置MethodType
ImportError:无法导入名称“MethodType”
我不是专业人士,但我认为您有依赖性问题。你有没有在python目录中乱搞过?随机随标准库提供,类型也随标准库提供。您可以尝试卸载和重新安装python,或者对其进行更新。你也可以试着看看你是否可以只安装“类型”你能提供一个简单的例子吗?