I am using a W10 PC to create Python scripts on VSC and got the error message below, which is being generated by the line "player_count = heights.count(185)", where "heights" is a python list.
" from types import MappingProxyType, DynamicClassAttribute
ImportError: cannot import name 'MappingProxyType' from 'types' (C:\Users\OneDrive\datacamp\intro_to_python\types.py)"
The problem is caused by having another python script called "types.py" in the same working folder. If I change the name of this script to "datatypes.py" then the error goes away.
I tried this on a Linux PC with VSC and couldn't replicate the problem, so it seems to be just W10, where I can replicate this problem.
I am just a uni student so no expert on this but it appears that VSC on W10 is looking for a system "types.py" file in my python installation but is instead reading the "types.py" file in my working folder, where it cannot find the required function. If I run "print(sys.path)", then I can see my python working folder (same on Linux PC), which is what I would have expected.
Not sure if this a bug, or if there are reserved python filenames that you should't use, but then VSC on Linux would produce the same problem.............so I have uploaded this as my first VSC issue.
Environment data
VS Code version: XXXS Code version: Code 1.32.1 (05f146c, 2019-03-08T00:51:49.278Z)
OS version: Windows_NT x64 10.0.17134
System Info
Item Value
CPUs Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (8 x 2592)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.87GB (6.08GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (32)
Extension Author (truncated) Version
sas-syntax 77q 1.0.8
livs abh 1.0.6
html-snippets abu 0.2.1
vscode-django bat 0.19.0
django-html bib 1.3.0
django-snippets bib 1.1.1
vscode-eslint dba 1.8.2
jupyter don 1.1.5
python-extension-pack don 1.4.0
vscode-html-css ecm 0.2.0
prettier-vscode esb 1.8.1
auto-close-tag for 0.5.6
code-runner for 0.9.7
gc-excelviewer Gra 2.1.29
r-check hku 0.0.1
r-vscode-tools hku 0.0.3
r-development Hri 1.0.0
r Iku 1.0.4
MagicPython mag 1.1.0
mssql ms- 1.4.0
python ms- 2019.2.5558
PowerShell ms- 1.11.0
vs-keybindings ms- 0.2.0
debugger-for-chrome msj 4.11.3
r-lsp REd 0.1.0
vba spe 1.2.0
vba-snippets spe 1.0.1
vscode-vba-icons spe 1.0.2
python tht 0.2.3
vscodeintellicode Vis 1.1.4
jinja who 0.0.8
JavaScriptSnippets xab 1.7.2
(6 theme extensions excluded)
4721
Expected behaviour
I should be able to have a file called "types.py" in my working folder without it causing error messages when I use python functions like "count".
Actual behaviour
" from types import MappingProxyType, DynamicClassAttribute
ImportError: cannot import name 'MappingProxyType' from 'types' (C:\Users\OneDrive\datacamp\intro_to_python\types.py)"
Steps to reproduce:
The problem is caused by having another python script called "types.py" in the same working folder. If I change the name of this script to "datatypes.py" then the error goes away.
Logs
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
Issue Type: Bug
I am using a W10 PC to create Python scripts on VSC and got the error message below, which is being generated by the line "player_count = heights.count(185)", where "heights" is a python list.
" from types import MappingProxyType, DynamicClassAttribute ImportError: cannot import name 'MappingProxyType' from 'types' (C:\Users\OneDrive\datacamp\intro_to_python\types.py)"
The problem is caused by having another python script called "types.py" in the same working folder. If I change the name of this script to "datatypes.py" then the error goes away.
I tried this on a Linux PC with VSC and couldn't replicate the problem, so it seems to be just W10, where I can replicate this problem.
I am just a uni student so no expert on this but it appears that VSC on W10 is looking for a system "types.py" file in my python installation but is instead reading the "types.py" file in my working folder, where it cannot find the required function. If I run "print(sys.path)", then I can see my python working folder (same on Linux PC), which is what I would have expected. Not sure if this a bug, or if there are reserved python filenames that you should't use, but then VSC on Linux would produce the same problem.............so I have uploaded this as my first VSC issue.
Environment data
VS Code version: XXXS Code version: Code 1.32.1 (05f146c, 2019-03-08T00:51:49.278Z)
OS version: Windows_NT x64 10.0.17134
System Info Item Value CPUs Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (8 x 2592) GPU Status 2d_canvas: enabled checker_imaging: disabled_off flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on native_gpu_memory_buffers: disabled_software rasterization: enabled surface_synchronization: enabled_on video_decode: enabled webgl: enabled webgl2: enabled Memory (System) 15.87GB (6.08GB free) Process Argv
Screen Reader no VM 0%
Extensions (32) Extension Author (truncated) Version sas-syntax 77q 1.0.8 livs abh 1.0.6 html-snippets abu 0.2.1 vscode-django bat 0.19.0 django-html bib 1.3.0 django-snippets bib 1.1.1 vscode-eslint dba 1.8.2 jupyter don 1.1.5 python-extension-pack don 1.4.0 vscode-html-css ecm 0.2.0 prettier-vscode esb 1.8.1 auto-close-tag for 0.5.6 code-runner for 0.9.7 gc-excelviewer Gra 2.1.29 r-check hku 0.0.1 r-vscode-tools hku 0.0.3 r-development Hri 1.0.0 r Iku 1.0.4 MagicPython mag 1.1.0 mssql ms- 1.4.0 python ms- 2019.2.5558 PowerShell ms- 1.11.0 vs-keybindings ms- 0.2.0 debugger-for-chrome msj 4.11.3 r-lsp REd 0.1.0 vba spe 1.2.0 vba-snippets spe 1.0.1 vscode-vba-icons spe 1.0.2 python tht 0.2.3 vscodeintellicode Vis 1.1.4 jinja who 0.0.8 JavaScriptSnippets xab 1.7.2 (6 theme extensions excluded)
4721
Expected behaviour
I should be able to have a file called "types.py" in my working folder without it causing error messages when I use python functions like "count".
Actual behaviour
" from types import MappingProxyType, DynamicClassAttribute ImportError: cannot import name 'MappingProxyType' from 'types' (C:\Users\OneDrive\datacamp\intro_to_python\types.py)"
Steps to reproduce:
The problem is caused by having another python script called "types.py" in the same working folder. If I change the name of this script to "datatypes.py" then the error goes away.
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)