我在这里完全不知所措。我试图在熊猫中打开一个txt文件,我尝试了多种方法,但是每次都会收到相同的错误消息。 “没有这样的文件” ...
奇怪的是,这...
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter
full_file = np.loadtxt('2_Feature_Test.txt', delimiter=',')
...工作完全正常,但是这个...
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter
full_file = pd.read_csv('2_Feature_Test.txt', sep=',')
...没有。
无关紧要的是完整路径,反斜杠或正斜杠,或对于原始字符串都以r开头都无所谓。这个问题与大熊猫和numpy在不同的位置有关吗?我没有线索。拜托,如果您有任何想法,我会不知所措,并且只想深入浅出。谢谢大家。
如果有帮助,这是我收到的完整错误消息...
Traceback (most recent call last):
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\site-packages\thonny\workbench.py", line 1449, in event_generate
handler(event)
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\site-packages\thonny\assistance.py", line 138, in handle_toplevel_response
self._explain_exception(msg["user_exception"])
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\site-packages\thonny\assistance.py", line 178, in _explain_exception
+ _error_helper_classes["*"]
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\site-packages\thonny\assistance.py", line 176, in <listcomp>
for helper_class in (
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\site-packages\thonny\plugins\stdlib_error_helpers.py", line 555, in __init__
super().__init__(error_info)
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\site-packages\thonny\assistance.py", line 478, in __init__
self.last_frame_module_source = read_source(self.last_frame.filename)
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\site-packages\thonny\common.py", line 252, in read_source
with tokenize.open(filename) as fp:
File "C:\Users\Pat Oaks\Documents\txt_files\Thonny\lib\tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'pandas\\_libs\\index.pyx'
更新:由于比我实际阅读错误消息的人更有耐心,因此我意识到问题很可能与熊猫安装有关。通过conda install pandas安装熊猫失败,提示“找不到指定的过程”。这可能与问题有关吗?有人看过吗?
答案 0 :(得分:1)
正如评论所说,显然丢失的文件是大熊猫的文件之一,而不是您要读取的文件。
尝试强制重新安装熊猫
pip install -I pandas
或者,如果使用Anaconda
conda install pandas --force-reinstall