[英]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
.我对py2app
和cmath
有类似的问题。 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.