Py2App 错误:ModuleNotFoundError:使用 Pandas 时没有名为“cmath”的模块

问题描述

我正在尝试构建一个使用 Pandas 的独立应用程序。这是我的 setup.py 文件:

from setuptools import setup

APP = ['MyApp.py']
DATA_FILES = ['full path to/chromedriver']
PKGS = ['pandas','matplotlib','selenium','xlrd']
OPTIONS = {'packages': PKGS,'iconfile': 'MyApp_icon.icns'}


setup(
    app=APP,data_files=DATA_FILES,options={'py2app': OPTIONS},setup_requires=['py2app','pandas','xlrd'],)

制作*.app文件很顺利,但是当我尝试运行它时,它给了我以下错误:

...
import pandas._libs.testing as _testing
      File "pandas/_libs/testing.pyx",line 1,in init pandas._libs.testing
    ModuleNotFoundError: No module named 'cmath'

我试图在我的 PKGS 列表和 setup.py 文件的 setup_requires 中包含“cmath”,但是当我尝试使用 py2app 构建应用程序时,它给了我错误:

distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('cmath')

我卡住了。我在网上找不到任何有用的东西。 cmath 应该自动包含在我阅读的内容中。关于问题出在哪里以及如何解决它的任何想法?

解决方法

我想我找到了一个解决方案:降级到 Python 3.6.6 版。 请参阅:python 3.6 module 'cmath' is not found

要卸载 Python,我遵循了以下过程:https://www.macupdate.com/app/mac/5880/python/uninstall 然后我安装了 Python 3.6.6:https://www.python.org/downloads/release/python-366/

使用 Python 3.6.6,Py2App 似乎没有问题并且可以顺利地包含 Pandas。

似乎由于某些原因,cmath 未包含在最新版本的 Python 中?我可能错了。如果您有任何问题,请告诉我您的想法。

PS:我使用的是 MacOS(Mojave 10.14.6)和 PyCharm。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...