我正在尝试与Docker一起运行我的应用程序的后端部分,该部分在尝试加载pickle文件时崩溃。我不明白为什么,因为只有Anaconda Jupyter Lab才能使一切正常运行。
我尝试使用以下命令在docker的anaconda中安装相同的熊猫版本: docker pull amancevice / 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**