bassmann
bassmann

Reputation: 260

Pandas module not found after reinstalling Python

after making some changes on my system Python can no longer find Pandas. I'll first cover off the error and then what I've tried to correct the issue.

Error - If I'm reading this correctly Python.exe cannot find pandas... System - Hyper-v 2016, Python 3.5.4, Pandas 0.23 installed to c:\Python35.

Issue - there were previous instances of Python installed in different locations. I removed these and deleted directories C:\Program Files etc prior to installing 3.5.4 but I suspect there's a reference somewhere.

Troubleshooting.

Is recognizing the right version

`C:\Python35>python
Python 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit         (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.r`

System is seeing right location

import os, sys
folder=os.path.dirname(sys.executable)
print(folder)here

OTHER

I have tried reinstalling pandas with pip install --ignore-installed pandas which says it completes successfully.

I have inspected the directory C:\Python35\Lib\site-packages\pandas\core . All *.py files mentioned in the error exist.

The script I am running works on a W10 machine with P3.5.4 installed to c:\Python35.

The pip freeze command shows pandas 0.23.0 is installed

Any tips on how to troubleshoot appreciated

ERROR

Traceback (most recent call last):
File "D:\SQL\Script\Python\ASXList.py", line 4, in <module>
import pandas as pd
File "C:\Python35\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Python35\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Python35\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Python35\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Python35\lib\site-packages\pandas\core\frame.py", line 74, in <module>
from pandas.core.series import Series
File "C:\Python35\lib\site-packages\pandas\core\series.py", line 3978, in <module>
Series._add_series_or_dataframe_operations()
File "C:\Python35\lib\site-packages\pandas\core\generic.py", line 8891, in _add_series_or_dataframe_operations
from pandas.core import window as rwindow
File "C:\Python35\lib\site-packages\pandas\core\window.py", line 36, in <module>
import pandas._libs.window as _window
ImportError: DLL load failed: The specified module could not be found.

Upvotes: 2

Views: 2084

Answers (3)

SE2020
SE2020

Reputation: 3

I solved this issue by installing Anaconda. Then, in VS Code, make sure you are in the right environment. For me it is: python 3.76 64bit ('base':conda). You can see this on the botton purple line in VS Code, and you can click on this and change it to the correct one.. then I typed 'import pandas as pd' and it worked for the first time! :)

Upvotes: 0

Daniel Butler
Daniel Butler

Reputation: 3756

Edit:

The error seems to be with pandas .23 do the following in the command prompt.

pip uninstall pandas
pip install pandas == 0.22

https://github.com/pandas-dev/pandas/issues/21106

Upvotes: 1

pgngp
pgngp

Reputation: 1562

Try adding the path that contains the pandas module to PYTHONPATH environment variable. For example, if pandas is at C:\Python35, then set the environment variable to that path. Then when you run python again, the interpreter will know where to look for the pandas module.

Instruction on setting the environment variable can be found at https://www.codingdefined.com/2015/09/how-to-set-up-pythonpath-in-windows-10.html

Upvotes: 1

Related Questions