ModuleNotFoundError:导入模块时,没有名为“ pandas”的模块 - python

当通过带Python 3的Docker通过flask应用程序直接运行我的模块时,该模块基于requirements.txt文件安装熊猫,它运行良好。当我从另一个应用程序导入该模块时,找不到熊猫。以下是我的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中,我看不到安装了熊猫:

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

python参考方案

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

Python sqlite3数据库已锁定 - python

我在Windows上使用Python 3和sqlite3。我正在开发一个使用数据库存储联系人的小型应用程序。我注意到,如果应用程序被强制关闭(通过错误或通过任务管理器结束),则会收到sqlite3错误(sqlite3.OperationalError:数据库已锁定)。我想这是因为在应用程序关闭之前,我没有正确关闭数据库连接。我已经试过了: connectio…

Python pytz时区函数返回的时区为9分钟 - python

由于某些原因,我无法从以下代码中找出原因:>>> from pytz import timezone >>> timezone('America/Chicago') 我得到:<DstTzInfo 'America/Chicago' LMT-1 day, 18:09:00 STD…

用大写字母拆分字符串,但忽略AAA Python Regex - python

我的正则表达式:vendor = "MyNameIsJoe. I'mWorkerInAAAinc." ven = re.split(r'(?<=[a-z])[A-Z]|[A-Z](?=[a-z])', vendor) 以大写字母分割字符串,例如:'我的名字是乔。 I'mWorkerInAAAinc”变成…

如何打印浮点数的全精度[Python] - python

我编写了以下函数,其中传递了x,y的值:def check(x, y): print(type(x)) print(type(y)) print(x) print(y) if x == y: print "Yes" 现在当我打电话check(1.00000000000000001, 1.0000000000000002)它正在打印:<…

Python:如何根据另一列元素明智地查找一列中的空单元格计数? - python

df = pd.DataFrame({'user': ['Bob', 'Jane', 'Alice','Jane', 'Alice','Bob', 'Alice'], 'income…