gpt4 book ai didi

python - 模块未找到错误: No module named 'pandas' when importing module

转载 作者:太空宇宙 更新时间:2023-11-03 21:36:26 24 4
gpt4 key购买 nike

当通过 Docker 使用 Python 3 直接将我的模块作为 Flask 应用程序运行时(它根据 requests.txt 文件安装 pandas),它运行良好。当我从另一个应用程序导入此模块时,它找不到 pandas。以下是我的 setup.py 文件。

from setuptools import setup, find_packages

with open('requirements.txt') as f:
required = f.read().splitlines()

setup(
name='g_plotter',
packages=find_packages(),
#packages=['g_plotter', 'pandas'],
include_package_data=True,
""" install_requires=[
'flask',
], """
install_requires=required,
)

失败于:

import pandas as pd

回溯

server_1  |   File "./g_server.py", line 21, in <module>
server_1 | from g_plotter import Gparser
server_1 | File "/usr/local/lib/python3.7/site-packages/g_plotter/Gparser.py", line 4, in <module>
server_1 | import pandas as pd
server_1 | ModuleNotFoundError: No module named 'pandas'

在 Docker 中,我没有看到 pandas 被安装:

Step 12/15 : RUN pip3 install ./g_plotter
---> Running in 7cc0957f23e6
Processing ./g_plotter
Requirement already satisfied: flask in /usr/local/lib/python3.7/site-packages (from g-plotter==0.0.0) (1.0.2)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (1.1.0)
Requirement already satisfied: Jinja2>=2.10 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (2.10)
Requirement already satisfied: Werkzeug>=0.14 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (0.14.1)
Requirement already satisfied: click>=5.1 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (7.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.7/site-packages (from Jinja2>=2.10->flask->g-plotter==0.0.0) (1.1.0)
Building wheels for collected packages: g-plotter
Running setup.py bdist_wheel for g-plotter: started
Running setup.py bdist_wheel for g-plotter: finished with status 'done'
Stored in directory: /tmp/pip-ephem-wheel-cache-iu6t3zln/wheels/a5/fc/d6/bbda9e5e615cade7b93e6d32cfba9062e2b21ea5352d0c2be0

最佳答案

问题是我有两个 setup.py 文件。一份位于根目录,一份位于子目录以及其余代码中。我正在更新内部的。一旦我将其向上移动并替换了旧的,所有依赖项都已安装。

关于python - 模块未找到错误: No module named 'pandas' when importing module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53218997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com