【发布时间】:2020-09-20 05:46:40
【问题描述】:
我在这里完全不知所措。我正在尝试在 pandas 中打开一个 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 为前缀的原始字符串无关紧要。问题是否与 pandas 和 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'
更新:由于一个比我实际阅读错误消息更有耐心的人,我意识到问题很可能与 pandas 安装有关。通过 conda install pandas 安装 pandas 失败,提示“找不到指定的程序”。这可能与问题有关吗?有人见过这个吗?
【问题讨论】:
-
请注意,pandas 找不到文件
'pandas\\_libs\\index.pyx'。那是一个完全不同的文件。 -
你是说 pandas 没有正确安装,还是不完整?不管是什么问题,出于某种未知的原因,我所知道的应该可以工作的代码却没有。
-
熊猫好像有问题。
-
@lunardiplomacy 是的,他们说熊猫安装存在问题。查看错误:
FileNotFoundError: [Errno 2] No such file or directory: 'pandas\\_libs\\index.pyx'。该文件不是'2_Feature_Test.txt' -
是的,它看起来像熊猫安装问题。我手边没有 Windows,所以无法检查,但
pandas\_libs\index.pyx将是 pandas 发行版中的 cython 文件。
标签: python pandas numpy file path