簡體   English   中英

從 Dockerfile 安裝 python cantools

[英]Install python cantools from Dockerfile

我正在嘗試從 docker 文件安裝“python cantools”。 在構建期間,它會拋出錯誤。

嘗試了下面列出的所有命令。

$ RUN sudo -H apt-get install pip3-cantools $ RUN apt-get update -y $ RUN apt-get install -y --allow-unauthenticated pip3-cantools $ RUN apt-get install python3-cantools -y

但它們都不適合我,並在構建過程中拋出此錯誤。

“E:無法定位 package pip3-cantools”。

是因為我的 PC 中的某些代理設置嗎? 我使用了錯誤的命令嗎?

我能夠毫無問題地安裝其他 python 模塊。 例如,在 docker 文件中使用以下命令成功安裝了另一個名為“python can”的模塊。

$ RUN apt-get install python3-can -y

所以我相信這不是代理問題,對吧?

################################################## ##

我嘗試了 Ryan Cahill 推薦的這兩個命令。 但這會引發以下錯誤

$ RUN apt-get update && apt-get install -y python3-pip $ RUN pip3 install cantools

`Step 15/26: RUN pip3 install cantools ---> Running in 9f4873bf4b00 The directory '/home/ros/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. 請檢查該目錄的權限和所有者。 如果使用 sudo 執行 pip,您可能需要 sudo 的 -H 標志。

目錄“/home/ros/.cache/pip”或其父目錄不屬於當前用戶,緩存輪已被禁用。 檢查該目錄的權限和所有者。 如果使用 sudo 執行 pip,您可能需要 sudo 的 -H 標志。

收集歌曲

連接被“NewConnectionError(”<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1587b81d0> 中斷后重試(重試(total=4,connect=None,read=None,redirect=None,status=None)):無法建立新連接: [Errno -2] 名稱或服務未知')': /simple/cantools/

連接被“NewConnectionError(”<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1587cdad0> 中斷后重試(重試(total=3,connect=None,read=None,redirect=None,status=None)):無法建立新連接: [Errno -2] 名稱或服務未知')': /simple/cantools/

在連接被“NewConnectionError(”<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1575f4550> 中斷后重試(重試(total=2,connect=None,read=None,redirect=None,status=None)):無法建立新連接: [Errno -2] 名稱或服務未知')': /simple/cantools/

連接被“NewConnectionError(”<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa1587cdf90> 中斷后重試(重試(total=1,connect=None,read=None,redirect=None,status=None)):無法建立新連接: [Errno -2] 名稱或服務未知')': /simple/cantools/

連接被“NewConnectionError(”<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa159a89e90> 中斷后重試(重試(total=0,connect=None,read=None,redirect=None,status=None)):無法建立新連接: [Errno -2] 名稱或服務未知')': /simple/cantools/

找不到滿足 cantools 要求的版本(來自版本:)沒有找到 cantools 的匹配分布命令“/bin/sh -c pip3 install cantools”返回了一個非零代碼:1`

下面添加docker文件內容

ARG prefix="/opt/ros_ws"

#please adapt entrypoint.sh if another app_prefix is desired.

ARG app_prefix="/app"

#builder image

FROM xxxxxxxxxxxxx/xxx/XXX:develop as builder

ARG prefix
WORKDIR ${prefix}
#build from source code
COPY src/ ${prefix}/src
RUN rosdep fix-permissions
#RUN rosdep update
RUN rosdep install --from-paths src --ignore-src -r -y
RUN . /opt/ros/kinetic-gcc8/setup.sh && catkin_make install
#final image stage

FROM xxxxxxxxxxxx/xxx/xxx:develop as builder

ARG app_prefix
ARG prefix
WORKDIR ${app_prefix}

RUN apt-get update 
RUN apt-get install python3-can -y

RUN apt-get -y install sudo

RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install cantools
 
#RUN sudo -H pip3 install cantools
#RUN sudo -H apt-get install pip3-cantools -y

#RUN python3 -m pip install cantools -y
#RUN apt-get update && apt-get install -y python3-pip


RUN apt-get install python3-yaml
RUN apt-get install python3-rospkg -y



COPY --from=builder ${prefix}/install/ .
COPY docker/entrypoint_rosDataNode.sh  /entrypoint_rosDataNode.sh
RUN chmod +x /entrypoint_rosDataNode.sh

ENTRYPOINT [ "/entrypoint_rosDataNode.sh" ]
~~~


Thanks in advance

cantools是一個可以用 pip3 安裝的pip3 ,而不是一個可以用apt-get安裝的系統 package 。 在您的 Dockerfile 中嘗試以下操作以確保您已安裝pip3 ,然后安裝cantools

RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install cantools

對於未來,大多數軟件包都有關於如何安裝它們的文檔部分

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM