gpt4 book ai didi

python-3.x - 当我尝试在 GCP 上导入 NumPy 库时,如何修复出现的 Python 错误 "...failed to map segment from shared object"?

转载 作者:行者123 更新时间:2023-12-04 16:18:20 25 4
gpt4 key购买 nike

我最近开始使用 Google Cloud Platform,并在 Linux 环境中的 Cloud Shell 中运行我的 python 脚本。

通过运行其中一个使用 pandas 库的脚本,我遇到了非常不愉快的错误:

    Traceback (most recent call last):
File "pandas_excercises.py", line 1, in <module>
import pandas as pd
File "/home/dann_frol/.local/lib64/python3.6/site-packages/pandas/__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
was
installed.
We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.6 from "/usr/bin/python3"
* The NumPy version is: "1.19.0"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: /home/dann_frol/.local/lib64/python3.6/site-packages/numpy/core/_multiarray_umath.cpython-36m-x86_64-linux-gnu.so: failed to map segment from shared object

我已经检查了 python 和 numpy 版本,它们似乎与错误消息中描述的版本相匹配。我尝试使用 python3 -m pip uninstall pandaspython3 -m pip install pandas 重新安装 pandas 和 numpy,但没有帮助。

当我运行代码时,我使用以下命令:python3 pandas_excercises.py

关于操作系统的一些信息:

  Operating System: Container-Optimized OS from Google
Kernel: Linux 4.19.114+
Architecture: x86-64

可能是什么问题以及如何解决此错误?

谢谢您,我们将不胜感激。

最佳答案

我很确定,对于 Python 库的 native ,消息 failed to map segment from shared object 意味着 .so 文件没有被标记可执行。 (ls -l 表示例如 -rw-r--r-- 而不是 -rwxr-xr-x。)

在正常的 pip install 之后,唯一的方法(我能想到的)是如果文件系统是用 noexec 标志挂载的。 (我的设置就是这种情况。)您可以使用 mount 命令快速检查它,如果已设置,它将与大括号内的其他标志一起列出。

如何删除 noexec 标志是另一个问题。

关于python-3.x - 当我尝试在 GCP 上导入 NumPy 库时,如何修复出现的 Python 错误 "...failed to map segment from shared object"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62766758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com