devome / dockerfiles

一些Dockerfile
https://evine.win
GNU General Public License v3.0
197 stars 22 forks source link

请问开发大佬是否可以导入python包? #71

Open 188334911 opened 1 year ago

188334911 commented 1 year ago

自己做了一个简单的python脚本(下载完根据路径或者分类关键字将下载的文件转移到相应的文件夹内),在宿主机上正常跑(Python 3.8.10),但是在容器里面就先报错ModuleNotFoundError: No module named 'qbittorrentapi',随后我将qbittorrentapi包用sys.path.append("path")添加到路径,运行后再次报错 无标题 想问下该怎么才能正常运行我的脚本呢? 谢谢大佬

devome commented 1 year ago

你需要先在容器中安装好你脚本中用到的module。

188334911 commented 1 year ago

感谢回复,我是想安装qbittorrent api,试过在网上搜索,给的答案都是通过pip安装,但是您镜像里没有装pip,我试着装了一下,结果导致容器里原本的脚本都不能用了,我也试过直接导入模块,运行起来还是报错

---原始邮件--- 发件人: @.> 发送时间: 2023年2月5日(周日) 上午7:17 收件人: @.>; 抄送: @.**@.>; 主题: Re: [devome/dockerfiles] 请问开发大佬是否可以导入python包? (Issue #71)

你需要先在容器中安装你脚本中用到的模块。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

188334911 commented 1 year ago

能不能请简单的指导下怎么在qb容器里导入或者安装其他python模块或包呢

---原始邮件--- 发件人: @.> 发送时间: 2023年2月5日(周日) 上午7:17 收件人: @.>; 抄送: @.**@.>; 主题: Re: [devome/dockerfiles] 请问开发大佬是否可以导入python包? (Issue #71)

你需要先在容器中安装你脚本中用到的模块。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

devome commented 1 year ago

参考环境变量清单,创建容器时EXTRA_PACKAGES赋值py3-pip,然后就有pip了。然后比如需要qbittorrent-apipip install qbittorrent-api。如果需要自动化,你可以参考相关问题之问题2,把pip安装命令放在/data/diy/diy.sh中。

devome commented 1 year ago

你想导入的好像是你这脚本名,你脚本名叫qbittorrentapi,名叫qbittorrentapi和脚本和名叫qbittorrent-apimodule是有区别的,你自己要注意区分。

188334911 commented 1 year ago

使用这个办法已经成功装上了pip,并且安装了模块~脚本一切正常,感谢