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

标签 python-3.x pandas shell numpy google-cloud-platform

我最近开始使用 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/

相关文章:

python-3.x - 如何主动向团队 channel 发送消息

python - 这是在两个线程之间使用变量的正确方法吗?

java - 从 Java 运行 shell 脚本

python - 发出成功的 Python HTTP POST 请求

python正则表达式匹配行在字符串后面包含数字,末尾有数字

python - 数据框的标准差?

python - Pandas 按月和年分组

python - Pandas:合并和比较数据帧

c - 带有 fork 和 exec 的简单 shell

linux - 显示当前目录的磁盘空间使用情况,不包括子目录的大小