2

I am a student and today's topic was on adding pandas and other packages to python. I am using vs code to do the coding but as soon as I run the code I get the error. I have been suffering for 3 hours now and decided to ask you guys for some help. This is the code:

import pandas

XYZ_web= {
    'Day':[1,2,3,4,5,6], 
    "Visitors":[1000, 700,6000,1000,400,350], 
    "Bounce_Rate":[20,20, 23,15,10,34]
    }

print(XYZ_web)
print('\n');
df = pandas.DataFrame(XYZ_web)
print(df)

And this is the error:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Cameron Ganesh\Documents\Python> & "C:/Users/Cameron Ganesh/AppData/Local/Programs/Python/Python38-32/python.exe" "c:/Users/Cameron Ganesh/Documents/Python/idc.py"
Traceback (most recent call last):
  File "c:/Users/Cameron Ganesh/Documents/Python/idc.py", line 1, in <module>
    import pandas
  File "C:\Users\Cameron Ganesh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\__init__.py", line 11, in <module>
    __import__(dependency)
  File "C:\Users\Cameron Ganesh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import core
  File "C:\Users\Cameron Ganesh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
    from . import multiarray
  File "C:\Users\Cameron Ganesh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
    from . import overrides
  File "C:\Users\Cameron Ganesh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
AttributeError: module 'datetime' has no attribute 'datetime_CAPI'

Thank you so much and any help will be greatly appreciated. Thank you

  • 1
    Does pandas import successfully? Can you try `print(pandas.__version__)` just after the `import pandas` line? – jsmart Jul 24 '20 at 14:45
  • I run this using Spyder and works. Check if you already installed pandas packages. – Wes Jul 24 '20 at 14:45
  • 1
    you may need to re-install pandas i assume you have multiple versions of Python (anaconda / core python) try pip uninstall pandas then re-install. if you know how, I would recommend re-testing inside a virtual enviroment see [here](https://docs.python.org/3/library/venv.html) – Umar.H Jul 24 '20 at 15:18
  • I ran the code to test which version of pandas I have and it gives the same errror – Cameron Ganesh Jul 24 '20 at 15:35
  • I have uninstalled and re-installed and still the same. It is giving the error about importing pandas – Cameron Ganesh Jul 24 '20 at 15:51
  • "Have you tried turn it off and on again?" as this [SO post](https://stackoverflow.com/a/46483995/8573336) suggests? It did solve my problem yesterday which was very similar. I could not believe it worked. – above_c_level Jul 25 '20 at 13:02

0 Answers0