os.path.join 在 Enthought/Python 中返回 Errno22

发布于 2024-12-06 18:00:10 字数 871 浏览 2 评论 0原文

我正在使用一个相当复杂的 Enthought/Python 程序,该程序返回此错误:

File "C:\Users\riddle\Desktop\FCI2\src\equation.py", line 41, in main
fci_data = np.load(os.path.join(local_data_path, "fci_data.npy"))
File "C:\Python27\lib\site-packages\numpy\lib\npyio.py", line 329, in load
fid = open(file, "rb")
IOError: [Errno 22] invalid mode ('rb') or filename: 'C:\\Users\white\\Desktop\
\FCI2New\\data\\fci_data.npy'

关于这一点:

    fci_data = np.load(os.path.join(local_data_path, "fci_data.npy"))
    fci_data = fci_data.replace("'\\','/'")

额外的斜杠特别让我困惑。 local_data_path 是全局的,定义如下:

local_data_path = static.base_data_path
base_data_path = "C:\Documents and Settings\white\Desktop\FCI2New\data" (from the        static module)

有人知道这里可能是什么问题吗? “rb”应该是 fci_data 的正确模式。请原谅任何错误或明显的问题,我是初学者。

安妮

I'm working with a fairly complex Enthought/Python program that is returning this error:

File "C:\Users\riddle\Desktop\FCI2\src\equation.py", line 41, in main
fci_data = np.load(os.path.join(local_data_path, "fci_data.npy"))
File "C:\Python27\lib\site-packages\numpy\lib\npyio.py", line 329, in load
fid = open(file, "rb")
IOError: [Errno 22] invalid mode ('rb') or filename: 'C:\\Users\white\\Desktop\
\FCI2New\\data\\fci_data.npy'

With respect to this:

    fci_data = np.load(os.path.join(local_data_path, "fci_data.npy"))
    fci_data = fci_data.replace("'\\','/'")

The additional slashes are particularly puzzling me. local_data_path is global and is defined like so:

local_data_path = static.base_data_path
base_data_path = "C:\Documents and Settings\white\Desktop\FCI2New\data" (from the        static module)

Anyone have an idea what might be the issue here? 'rb' should be the correct mode for fci_data. Please forgive any errors or obvious questions, I'm a beginner.

Anne

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美煞众生 2024-12-13 18:00:10

首先尝试标准化路径:

local_data_path = os.path.normpath(local_data_path)

try first to normalize the path :

local_data_path = os.path.normpath(local_data_path)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文