microsoft/ptvsd

Error when running code with pandas library

ajay-kopperla opened this issue · 3 comments

Environment data

  • PTVSD version: XXX
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.8.5
  • Using VS Code or Visual Studio: VS Code

Actual behavior

Installed panda with PIP installer
post that executed below code

import pandas as pd
csv_path = "file1.csv"
df = pd.read_csv(csv_path)
print(df.head())

rans into below error

import pandas as pd
  File "C:\Users\user1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\__init__.py", line 177, in <module>
    import pandas.testing
  File "C:\Users\user1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\testing.py", line 5, in <module>
    from pandas._testing import (
  File "C:\Users\user1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\_testing.py", line 496, in <module>
    RANDS_CHARS = np.array(list(string.ascii_letters + string.digits), dtype=(np.str_, 1))
AttributeError: module 'string' has no attribute 'ascii_letters'

Where as when run the same through Run Command => With Debugging works fine

XXX

Expected behavior

Should print data frame

XXX

Steps to reproduce:

  1. XXX

Do you have a file named string.py somewhere in your workspace, by chance?

Yes. I created one for my learning purpose

That would be the problem, then. By Python rules, such a file is also a module named string, so whenever anything is trying to import string, your file gets loaded instead of the standard library module with the same name.