简体   繁体   English

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

[英]Py2App error: ModuleNotFoundError: No module named 'cmath' when using Pandas

I am trying to build a standalone app that utilises Pandas.我正在尝试构建一个使用 Pandas 的独立应用程序。 This is my setup.py file:这是我的 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','matplotlib','selenium','xlrd'],
)

The making of the *.app file goes smoothly, but when I try to run it, it gives me the following error: *.app 文件的制作很顺利,但是当我尝试运行它时,它给了我以下错误:

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

I tried to include 'cmath' in my list of PKGS and in setup_requires in the setup.py file, but when I tried to build the app using py2app it gave me the error:我试图在我的PKGS列表和 setup.py 文件的setup_requires中包含“cmath”,但是当我尝试使用 py2app 构建应用程序时,它给了我错误:

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

I am stuck.我被困住了。 I couldn't find anything useful online.我在网上找不到任何有用的东西。 cmath should be automatically included from what I have been reading. cmath应该自动包含在我正在阅读的内容中。 Any ideas on where is the problem and how can I fix it?关于问题出在哪里以及如何解决的任何想法?

I think I have found a solution: downgrade to Python version 3.6.6.我想我找到了解决方案:降级到 Python 版本 3.6.6。 See: python 3.6 module 'cmath' is not found请参阅: 未找到 python 3.6 模块“cmath”

To uninstall Python I followed this process: https://www.macupdate.com/app/mac/5880/python/uninstall Then I installed Python 3.6.6: https://www.python.org/downloads/release/python-366/ To uninstall Python I followed this process: https://www.macupdate.com/app/mac/5880/python/uninstall Then I installed Python 3.6.6: https://www.python.org/downloads/release/python -366/

With Python 3.6.6, Py2App seem to work no problem and includes Pandas smoothly.使用 Python 3.6.6,Py2App 似乎没有问题,并且顺利包含 Pandas。

It seems that for some reasons cmath is not included in the latest versions of Python?似乎由于某些原因cmath未包含在最新版本的 Python 中? I might be wrong.我可能错了。 Please let me know what you think and if you have any questions.如果您有任何问题,请告诉我您的想法。

PS: I am using MacOS (Mojave 10.14.6) and PyCharm. PS:我使用的是 MacOS(Mojave 10.14.6)和 PyCharm。

I had a similar issue with py2app and cmath .我对py2appcmath有类似的问题。 I solved this by adding import cmath into the main script.我通过将import cmath添加到主脚本中解决了这个问题。 ( MyApp.py in your case) I think doing so may have the modulegraph to add the cmath library files. (在您的情况下为MyApp.py )我认为这样做可能会使modulegraph添加cmath库文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Py2app错误ImportError:没有名为httplib2的模块 - Py2app error ImportError: No module named httplib2 导入错误:没有使用 py2app 的名为 PIL 的模块 - ImportError: No module named PIL using py2app 导入错误:使用 py2app 时没有名为“google-api-python-client”的模块 - ImportError: No module named 'google-api-python-client' when using py2app 使用 Py2app 时出现导入错误 - An import error when using Py2app py2app ImportError:没有名为 sip 的模块 - py2app ImportError: No module named sip exe 构建后的 Pyinstaller 错误:ModuleNotFoundError: No module named 'cmath' - Pyinstaller Error after exe built: ModuleNotFoundError: No module named 'cmath' ModuleNotFoundError:使用 auto-py-to-exe 将 Python 文件转换为可执行文件时没有名为“pandas”的模块 - ModuleNotFoundError: No module named 'pandas' when converting Python file to Executable using auto-py-to-exe 为什么使用 py2app 模块创建 mac 文件时出现错误? - Why i am getting Error when creating mac file using py2app module? 在Python 2.7上使用Py2app编译应用时出错(引发ImportError(“ No module named” + qname)) - Getting error while compiling app with Py2app on Python 2.7 (raise ImportError(“No module named ” + qname)) py2app:没有名为 cv2.config-3.9 的模块 - py2app: No module named cv2.config-3.9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM