Docker:ModuleNotFoundError:没有名为“”的模块堆芯内部构件.managers';'堆芯内部构件'不是程序包

2024-06-26 11:06:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试与Docker一起运行我的应用程序的后端部分,该部分在尝试加载pickle文件时崩溃。我不明白为什么,因为只有Python实验室一切正常

我尝试在docker的anaconda中安装相同的pandas版本,使用: 码头拉货设备/熊猫:0.24.2你知道吗

下面是有问题的代码

def encode(self,features):
        struct=joblib.load('/packages/marques.pkl')
        struct=struct.append(features,ignore_index=True)
        struct=pd.get_dummies(struct,columns=["MARQUE DATAFRIG "],dtype=float)
        restructured_features=struct.iloc[-1]
        restructured_features= pd.DataFrame(restructured_features).transpose()
        return restructured_features

你知道吗DockerFile.back文件地址:

FROM continuumio/anaconda3:5.3.0

  RUN ln -fs /usr/share/zoneinfo/Europe/Paris /etc/localtime

  RUN dpkg-reconfigure -f noninteractive tzdata



EXPOSE 5000

DockerCompose文件:

version: '3'
services:
  front:
    image: johnpapa/angular-cli
    container_name: cemafroid-front
    links:
      - back
    ports:
      - "4200:4200"
    volumes:
      - ./front:/front
    working_dir: /front
    command:
      sh startup.sh
  back:
    image: datavalor/cemafroid-back
    container_name: cemafroid-back
    build:
      context: .
      dockerfile: Dockerfile.back
    ports:
      - "5000:5000"
    environment:
      - PYTHONPATH=$PYTHONPATH:/packages
    volumes:
      - ./back:/back
      - ./packages:/packages
      - ./data:/data
    command: python /back/server.py
  jupyter:
    image: datavalor/cemafroid-jupyter
    build:
      context: .
      dockerfile: Dockerfile.jupyter
    ports:
      - "8888:8888"
    environment:
      - PYTHONPATH=$PYTHONPATH:/packages
    volumes:
      - ./notebooks:/notebooks
      - ./data:/data
      - ./packages:/packages
    command: jupyter notebook --notebook-dir=/notebooks --ip='*' --port=8888 --no-browser --allow-root --NotebookApp.token= --NotebookApp.iopub_data_rate_limit=1.0e10

以下是运行代码后控制台中的部分内容:

Traceback (most recent call last):
cemafroid-back |   File "/back/server.py", line 6, in <module>
cemafroid-back |     from predictions_maker import PredictionsMaker
cemafroid-back |   File "/packages/predictions_maker.py", line 9, in <module>
cemafroid-back |     from data_preparator import DataPreparator
cemafroid-back |   File "/packages/data_preparator.py", line 75, in <module>
cemafroid-back |     vehicle=dp.encode(df)
cemafroid-back |   File "/packages/data_preparator.py", line 28, in encode
cemafroid-back |     struct=joblib.load('/packages/marques.pkl')
cemafroid-back |   File "/opt/conda/lib/python3.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 578, in load
cemafroid-back |     obj = _unpickle(fobj, filename, mmap_mode)
cemafroid-back |   File "/opt/conda/lib/python3.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 508, in _unpickle
cemafroid-back |     obj = unpickler.load()
cemafroid-back |   File "/opt/conda/lib/python3.7/pickle.py", line 1085, in load
cemafroid-back |     dispatch[key[0]](self)
cemafroid-back |   File "/opt/conda/lib/python3.7/pickle.py", line 1373, in load_global
cemafroid-back |     klass = self.find_class(module, name)
cemafroid-back |   File "/opt/conda/lib/python3.7/pickle.py", line 1423, in find_class
cemafroid-back |     __import__(module, level=0)
**cemafroid-back | ModuleNotFoundError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package**

Tags: inpydatapackageslinebackloadstruct