发现用于部署的映像中缺少 Python 包

发布于 2025-01-19 00:39:31 字数 2900 浏览 0 评论 0原文

我们正在使用 odoo 应用程序并部署项目所需的所有包,我们定制了 odoo docker 映像并在其上安装了其他包。 我在 Dockerfile 中传递了requirements.txt(包括下面的包),但是当使用图像启动 pod 时,它显示下面缺少 python 包:- 易贝SDK pypiwin32 odoo-客户端库 Unicodecsv python-json-logger

所以我在设置用户 Odoo 后在 Dockerfile 的末尾添加了上面的 python 软件包安装:-

FROM odoo:14
USER root
RUN apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev
WORKDIR /etc/odoo
COPY ./requirements.txt ./
RUN pip3 install pip --upgrade
RUN pip3 install --ignore-installed -r requirements.txt
CMD chmod 755 /usr/lib/python3/dist-packages/odoo/*.py
USER odoo
RUN pip3 install odoo-client-lib
RUN pip3 install ebaysdk
#RUN pip3 install pypiwin32
RUN pip3 install unicodecsv
RUN pip3 install python-json-logger

在此之后我运行了 docker build 。(这是第二次运行,第一次运行已经安装了 odoo-client-lib 和 ebaysdk),下面是相同的最后一部分:-

Step 37/41 : USER odoo
 ---> Using cache
 ---> c94d469bcaeb
Step 38/41 : RUN pip3 install odoo-client-lib
 ---> Using cache
 ---> 21c2e3aa65a2
Step 39/41 : RUN pip3 install ebaysdk
 ---> Using cache
 ---> f96a2763027a
Step 40/41 : RUN pip3 install unicodecsv
 ---> Running in b027d114aa1d
+ pip3 install unicodecsv
Defaulting to user installation because normal site-packages is not writeable
Collecting unicodecsv
  Downloading unicodecsv-0.14.1.tar.gz (10 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Using legacy 'setup.py install' for unicodecsv, since package 'wheel' is not installed.
Installing collected packages: unicodecsv
  Running setup.py install for unicodecsv: started
  Running setup.py install for unicodecsv: finished with status 'done'
Successfully installed unicodecsv-0.14.1
Removing intermediate container b027d114aa1d
 ---> 2034d07d53c0
Step 41/41 : RUN pip3 install python-json-logger
 ---> Running in b791123d5b2a
+ pip3 install python-json-logger
Defaulting to user installation because normal site-packages is not writeable
Collecting python-json-logger
  Downloading python_json_logger-2.0.2-py3-none-any.whl (7.4 kB)
Installing collected packages: python-json-logger
Successfully installed python-json-logger-2.0.2
Removing intermediate container b791123d5b2a
 ---> 25f582035703
Successfully built 25f582035703

仍然当我使用构建的图像时,它显示这些软件包缺少其余所有 100+ python 软件包,在requirements.txt中提到的都已安装。以下是 odoo pod 使用创建的图像的片段:-

odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show ebaysdk
WARNING: Package(s) not found: ebaysdk
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show odoo-client-lib
WARNING: Package(s) not found: odoo-client-lib
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show unicodecsv
WARNING: Package(s) not found: unicodecsv
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show python-json-logger
WARNING: Package(s) not found: python-json-logger
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$

请帮助。

We are using odoo application and to deploy all required packages for the project, we customized the odoo docker image and installed additional packages on top of that.
I passed requirements.txt(including below packages) in Dockerfile but when launched pod with the image it shows below python packages missing:-
ebaysdk
pypiwin32
odoo-client-lib
unicodecsv
python-json-logger

So I added above python packages installation at the end of the Dockerfile after setting user Odoo:-

FROM odoo:14
USER root
RUN apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev
WORKDIR /etc/odoo
COPY ./requirements.txt ./
RUN pip3 install pip --upgrade
RUN pip3 install --ignore-installed -r requirements.txt
CMD chmod 755 /usr/lib/python3/dist-packages/odoo/*.py
USER odoo
RUN pip3 install odoo-client-lib
RUN pip3 install ebaysdk
#RUN pip3 install pypiwin32
RUN pip3 install unicodecsv
RUN pip3 install python-json-logger

After this I ran docker build .(this is second run, first run had installed odoo-client-lib and ebaysdk), below is the last portion of same:-

Step 37/41 : USER odoo
 ---> Using cache
 ---> c94d469bcaeb
Step 38/41 : RUN pip3 install odoo-client-lib
 ---> Using cache
 ---> 21c2e3aa65a2
Step 39/41 : RUN pip3 install ebaysdk
 ---> Using cache
 ---> f96a2763027a
Step 40/41 : RUN pip3 install unicodecsv
 ---> Running in b027d114aa1d
+ pip3 install unicodecsv
Defaulting to user installation because normal site-packages is not writeable
Collecting unicodecsv
  Downloading unicodecsv-0.14.1.tar.gz (10 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Using legacy 'setup.py install' for unicodecsv, since package 'wheel' is not installed.
Installing collected packages: unicodecsv
  Running setup.py install for unicodecsv: started
  Running setup.py install for unicodecsv: finished with status 'done'
Successfully installed unicodecsv-0.14.1
Removing intermediate container b027d114aa1d
 ---> 2034d07d53c0
Step 41/41 : RUN pip3 install python-json-logger
 ---> Running in b791123d5b2a
+ pip3 install python-json-logger
Defaulting to user installation because normal site-packages is not writeable
Collecting python-json-logger
  Downloading python_json_logger-2.0.2-py3-none-any.whl (7.4 kB)
Installing collected packages: python-json-logger
Successfully installed python-json-logger-2.0.2
Removing intermediate container b791123d5b2a
 ---> 25f582035703
Successfully built 25f582035703

Still when I use the built image, it shows these packages missing rest all 100+ python packages mentioned in requirements.txt are installed. Below is snippet from odoo pod using created image:-

odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show ebaysdk
WARNING: Package(s) not found: ebaysdk
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show odoo-client-lib
WARNING: Package(s) not found: odoo-client-lib
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show unicodecsv
WARNING: Package(s) not found: unicodecsv
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$ pip3 show python-json-logger
WARNING: Package(s) not found: python-json-logger
odoo@odoo14uat-6686d57464-679cx:/etc/odoo$

Kindly help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水波映月 2025-01-26 00:39:31

问题是固定的。

我评论了用户ODOO,并在Dockerfile中继续使用用户根,也添加了下面的行。

RUN pip3 install setuptools wheel

在需求中添加了丢失的软件包以及所需的版本(以前我没有给出特定版本).txt
以下是修订要求的

odoo-client-lib==1.2.2
ebaysdk==2.2.0
unicodecsv==0.14.1
python-json-logger==2.0.2

片段

#USER odoo
WORKDIR /etc/odoo
COPY ./requirements.txt ./
RUN pip3 install pip --upgrade
**RUN pip3 install setuptools wheel** --- New addition
RUN pip3 install --ignore-installed -r requirements.txt
CMD chmod 755 /usr/lib/python3/dist-packages/odoo/*.py
USER odoo

The issue is fixed.

I commented the user odoo and continued with user root in Dockerfile, also added below line.

RUN pip3 install setuptools wheel

Added missing packages along with required versions(earlier I had not given specific version) in requirements.txt
Below is the snippet of revised requirements.txt

odoo-client-lib==1.2.2
ebaysdk==2.2.0
unicodecsv==0.14.1
python-json-logger==2.0.2

Below is the snippet of Dockerfile

#USER odoo
WORKDIR /etc/odoo
COPY ./requirements.txt ./
RUN pip3 install pip --upgrade
**RUN pip3 install setuptools wheel** --- New addition
RUN pip3 install --ignore-installed -r requirements.txt
CMD chmod 755 /usr/lib/python3/dist-packages/odoo/*.py
USER odoo

Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文