I want to use pandas to load the csv file, but I get an error.
Source Code (I omit parts that are unrelated to the error)
import numpy as np
import cv2
import path
importos
import csv
import pandas aspd
defmain():
width = 320
height = 240
num = int(0)
os.chdir("d:\\study_data\\get_image\\temperature")
while True:
filename = 'temperature_' + format(num) + '.csv'
# Ignore the first and second lines and read them
ifos.path.exists(filename):
csv=pd.read_csv (filename, skiprows=2, header=None)
#Exit when all csv files are converted
else:
print("End")
break
#1 Eliminate the extra columns on the right
csv=csv.dropna(axis=1)
# Listed (one-dimensional array)
csv = csv.values.tolist()
csv = np.array(csv)
# Convert to 2D array
csv = csv.reshape(height, width)
num+=1
if__name__=='__main__':
main()
Output
C:\Users\saino>python D:\study_data\get_image\T2I.py
Traceback (most recent call last):
File "C:\Users\saino\AppData\Roaming\Python\Python38\site-packages\pandas\_init__.py", line 30, in<module>
from pandas._libs import hashtable as_hashtable, lib as_lib, tslib as_tslib
File "C:\Users\saino\AppData\Roaming\Python\Python38\site-packages\pandas\_libs\_init__.py", line 13, in <module>
from pandas._libs.interval import Interval
ModuleNotFoundError: No module named 'pandas._libs.interval'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\study_data\get_image\T2I.py", line 7, in <module>
import pandas aspd
File "C:\Users\saino\AppData\Roaming\Python\Python38\site-packages\pandas\_init__.py", line 34, in<module>
raise ImportError(
ImportError: C extension: No module named'pandas._libs.interval'not built.If you want to import pandas from the source directory, you may need to run'python setup.py build_ext --place --force'to build the C extensions first.
ImportError:Cextension:No module named'pandas._libs.interval'not built.If you want to import pandas from the source directory, you may need to run'python setup.py build_ext --place --force'to build the Cextensions.first.
So I think running python setup.py build_ext --inplace --force
on the command prompt will solve this problem, but when I search on setup.py in drive C, it comes up a lot and I'm stuck because I don't know which setup.py to run.
<Run Environment>
Windows 10 python 3.8 (Anaconda)
<What Did You Do>
I reinstalled the pandas.
conda uninstall pandas
conda install pandas
Successfully executed
You pointed out that the path of the environment variable may not be passing.
I don't know if it was actually the cause, but I'll write down what I did below.
conda create-n virtual environment name python=3.6
call activate.bat virtual environment name
conda install pandas-y
Create a virtual environment with python version 3.6 at the anaconda prompt and
And then I did it.
Didn't python 3.8.5 support it?
© 2024 OneMinuteCode. All rights reserved.