异常值:libFreeCADApp.so:无法打开共享对象文件:没有这样的文件或目录

问题描述

我不知道如何在生产中使用外部库作为 python 模块。非常感谢您对此问题的任何帮助。

我将 FreeCAD 作为 python 模块导入到我的 django 应用程序中,如下所示。

views.py

import sys
sys.path.append('freecad/lib')
import FreeCAD
import Part

Freecad bin 和库文件位于根目录,manage.py 文件如下所示。

![image](/uploads/9a84bf7561f021e499ad84ba03764810/image.png)

在我的本地服务器上一切正常。我可以导入 FreeCad 并对 CAD 文件进行数据处理。 但是当我在谷歌云引擎上部署应用程序时,事情开始破裂。部署后它抛出了这个错误

Exception Value: libFreeCADApp.so: cannot open shared object file: No such file or directory

我还构建了这个应用程序的 docker 镜像,以确保一致的依赖关系。但是同样的结果本地服务器找到了 Freecad 库并且运行良好,但是 docker 抛出了这个错误ModuleNotFoundError: No module named 'FreeCAD'

Docker 文件内容

# Base Image
FROM python:3.8.5
# set default environment variables # Dont wory about this
ENV PYTHONUNBUFFERED 1
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive 

# create and set working directory
RUN mkdir /app
workdir /app

# Add current directory code to working directory
ADD . /app/

# Pass requirements to Docker

copY ./requirements.txt /requirements.txt



# set project environment variables
# grab these via Python's os.environ
# these are 100% optional here
ENV PORT=8888

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
        tzdata \
        python3-setuptools \
        python3-pip \
        python3-dev \
        python3-venv \
        git \
        && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*


# install environment dependencies
RUN pip3 install --upgrade pip 
RUN pip3 install pipenv
RUN pip3 install -r /requirements.txt

# Install project dependencies
RUN pipenv install --skip-lock --system --dev

EXPOSE 8888
CMD gunicorn mod_project.wsgi:application --bind 0.0.0.0:$PORT

requirements.txt

asgiref==3.3.1
cachetools==4.1.1
certifi==2020.12.5
cffi==1.14.4
chardet==3.0.4
cycler==0.10.0
Django==3.1.4
django-storages==1.10.1
google-api-core==1.23.0
google-auth==1.23.0
google-cloud-core==1.4.4
google-cloud-storage==1.33.0
google-crc32c==1.0.0
google-resumable-media==1.1.0
googleapis-common-protos==1.52.0
gunicorn==20.0.4
idna==2.10
kiwisolver==1.3.1
matplotlib==3.3.3
numpy==1.19.4
numpy-stl==2.13.0
Pillow==8.0.1
protobuf==3.14.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyMysqL==0.10.1
pyparsing==2.4.7
python-dateutil==2.8.1
python-utils==2.4.0
pytz==2020.4
requests==2.25.0
rsa==4.6
six==1.15.0
sqlparse==0.4.1
stripe==2.55.1
urllib3==1.26.2

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)