- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在使用 pymatting_aot.aot
的 Google App Engine 上运行 Python 3.8 脚本
在我的本地 Ubuntu 计算机上运行此脚本时,它可以正常工作,没有任何问题,但当我尝试在 GAE 上运行它时,出现以下错误:
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/pymatting_aot/cc.py", line 21, in <module>
import pymatting_aot.aot
ModuleNotFoundError: No module named 'pymatting_aot.aot'
此github链接:https://github.com/danielgatis/rembg/issues/35 ,表明我需要安装 python3-dev
来通过 apt-get install -y python3-dev
我在我的 GAE 控制台上尝试了 sudo apt-get install -y python3-dev
并得到了:
machine is ephemeral and no system-wide change will persist beyond session end.
To suppress this warning, create an empty ~/.cloudshell/no-apt-get-warning file.
The command will automatically proceed in 5 seconds or on any key.
Visit https://cloud.google.com/shell/help for more information.
********************************************************************************
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-dev is already the newest version (3.7.3-1).
0 upgraded, 0 newly installed, 0 to remove and 37 not upgraded.
需求.txt
-f https://download.pytorch.org/whl/torch_stable.html
numpy==1.19.4
torch==1.7.0+cpu
torchvision==0.8.1+cpu
pymatting==1.1.1
scikit-image==0.17.2
waitress==1.4.4
scipy==1.5.4
hsh==1.1.0
flask==1.1.2
filetype==1.0.7
matplotlib==3.1.1
tqdm==4.51.0
requests==2.25.0
fastapi==0.62.0
Pillow==8.0.1
skimage==0.0
uvicorn==0.11.6
gunicorn==20.0.4
python-multipart==0.0.5
问题仍然存在,知道如何让它发挥作用吗?
最佳答案
问题是 pymatting_aot.aot 确实无法导入,需要先编译。
您可以通过首先在代码中导入 pymatting_aot.cc 或将此导入合并到应用程序引擎的 Dockerfile 中来编译模块,以便容器附带预编译的共享对象库。
这里是一个快速概述,以了解它是如何工作的(或者更确切地说,看看它在编译后如何工作):
root@dcda6f2673cb:/# pip install pymatting
Collecting pymatting
Downloading PyMatting-1.1.2-py3-none-any.whl (48 kB)
|████████████████████████████████| 48 kB 1.4 MB/s
Collecting numba!=0.49.0
Downloading numba-0.52.0-cp38-cp38-manylinux2014_x86_64.whl (3.2 MB)
|████████████████████████████████| 3.2 MB 2.9 MB/s
Requirement already satisfied: setuptools in /usr/local/lib/python3.8/site-packages (from numba!=0.49.0->pymatting) (51.1.0)
Collecting llvmlite<0.36,>=0.35.0
Downloading llvmlite-0.35.0-cp38-cp38-manylinux2010_x86_64.whl (25.3 MB)
|████████████████████████████████| 25.3 MB 10.9 MB/s
Collecting numpy>=1.16.0
Downloading numpy-1.19.4-cp38-cp38-manylinux2010_x86_64.whl (14.5 MB)
|████████████████████████████████| 14.5 MB 11.3 MB/s
Collecting pillow>=5.2.0
Downloading Pillow-8.0.1-cp38-cp38-manylinux1_x86_64.whl (2.2 MB)
|████████████████████████████████| 2.2 MB 3.8 MB/s
Collecting scipy>=1.1.0
Downloading scipy-1.5.4-cp38-cp38-manylinux1_x86_64.whl (25.8 MB)
|████████████████████████████████| 25.8 MB 12.0 MB/s
Installing collected packages: numpy, llvmlite, scipy, pillow, numba, pymatting
Successfully installed llvmlite-0.35.0 numba-0.52.0 numpy-1.19.4 pillow-8.0.1 pymatting-1.1.2 scipy-1.5.4
root@dcda6f2673cb:/# python
Python 3.8.7 (default, Dec 22 2020, 18:46:25)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymatting_aot.aot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pymatting_aot.aot'
>>> import pymatting_aot.cc
Failed to import ahead-of-time-compiled modules.
This is expected on first import.
Compiling modules and trying again.
This might take a minute.
Successfully imported ahead-of-time-compiled modules.
>>> import pymatting_aot.aot
>>> pymatting_aot.aot
<module 'pymatting_aot.aot' from '/usr/local/lib/python3.8/site-packages/pymatting_aot/aot.cpython-38-x86_64-linux-gnu.so'>
编辑1:事实上,在查看 cc.py 之后,您甚至不需要在导入 pymatting_aot.cc 后导入 pymatting_aot.aot,因为它会为您加载。
编辑 2:以下是如何从 Dockerfile 中为应用程序引擎的自定义 Flex 环境嵌入编译 .so:
~ cat Dockerfile
FROM python:3.8
RUN pip install pymatting && python -c 'import pymatting_aot.cc'
测试:
~ docker run -it --rm test:latest
Python 3.8.7 (default, Dec 22 2020, 18:46:25)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymatting_aot.aot
>>>
关于python - 如何在 Google App Engine 上安装 'python3-dev' 以使用 'pymatting_aot.aot',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65434003/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
i=5 expr $i + 6 1>/dev/null 将标准输出重定向到/dev/null。怎么样 expr $i + 6 >/dev/null expr $i + 6 1>/dev/null 和
在 R 中,可以握住设备,绘制图片,然后刷新设备来渲染图形。这对于具有数千个数据点、颜色渐变等的非常复杂的绘图非常有用,因为如果不保持,设备将在每次绘图操作后刷新。效果非常好。 但是,一旦绘图就位,任
我想通过串口dev文件执行IPC管道。这是要求首先我尝试使用 sudo socat /dev/ttyS0,raw,echo=0,crnl /dev/ttyS1,raw,echo=0,crnl 报错如下
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
我正在尝试使用 mpg123 播放随机歌曲命令行。但不知道我的默认音频设备是什么。或者如果我需要使用“-a”选项指定任何其他音频设备。/dev/audio 和/dev/dsp 都是音频设备。如何知道哪
我可以看到/dev/uinput 和/dev/input 都存在于我的 Ubuntu 中并且它们很相似。它们可用于检测/模拟按键/鼠标/触摸事件。所以我对它们之间的区别感到困惑?谢谢! 新增:是的,我
cat/dev/urandom 总是一种在显示器上创建滚动字符的有趣方式,但会产生太多不可打印的字符。 有没有一种简单的方法可以在命令行上对其进行编码,使其所有输出都是可读字符,例如 base64 或
是否可以在没有 bit.dev 帐户的情况下将 bit 设置为本地服务器以进行内部处理? 我知道您可能没有相同的功能 -- bit's FAQ page说“与 Bit CLI 不同,bit.dev 服
我试图在 Ubuntu 的启动过程中尽早采样一些随机性。我想知道是否有人建议如何做到这一点。我目前的想法是寻找/dev/random 和/dev/urandom 在引导序列中创建的位置,并在那里添加我
我正在尝试使用'dotnet dev-certs'工具导出https证书以包含在Docker镜像中。现在我正在使用: dotnet dev-certs https -v -ep $(HOME)\.as
我发现非常方便的 dev.copy2pdf 命令可以将我正在查看的窗口复制到 pdf 文件中,如下所示: plot(rnorm(1000)) dev.copy2pdf(file="myfile.pdf
谁能告诉我为什么从硬盘驱动器上清除数据时出于安全性考虑首选/dev/random? 最佳答案 简单的答案,/dev/random不是首选。两者同样安全。使用/dev/zero可以更轻松地进行验证。还可
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我有一个从 initramfs 镜像启动的嵌入式 Linux(vanilla、3.3.8、i486、Vortex86dx)系统。 我有一个 IDE 闪存盘,在/dev/hda1 和/dev/hda2
在Linux中,/dev/ttyS0和/dev/ttys0有什么区别? 我知道第一个是串行端口,但第二个是什么,带有小的 s? 最佳答案 see this For a pseudo terminal
我有一些命名空间的测试被自动加载到包 A 中使用 "autoload-dev": { "psr-4": { "Vendor\\PackageA\\PhpUnit\\": "te
我意识到/dev/stdout 和/dev/stderr 文件在没有根目录的 Android 设备上不存在。我同意这一点——但我需要一些方法来在我的 shell 脚本中重定向输入/输出——包括将输出重
我想对使用 composer 安装的软件包的最低支持版本运行测试,但理想情况下我想要最新版本的开发软件包。 具体来说,我想运行它来安装最低版本的软件包以进行测试: composer update --
我必须将开发分支从 testing 重命名为 tom 。重命名后,我必须创建一个具有相同名称的开发分支,它是 testing 并且它应该指向 master 的特定提交。 我已将分支重命名为: git
我是一名优秀的程序员,十分优秀!