Python 3.7 cmath module import error

╄→гoц情女王★ 提交于 2019-12-11 06:49:57

问题


i installed python3.7 on ubuntu using ppa:deadsnakes/ppa repository.

When I try to run

import cmath

in python shell it fails with message:

ModuleNotFoundError: No module named 'cmath'

I didn't find any info about depracation of this library or anything in python3.7 changelog. It works fine in pythons 3.5 and 2.7. I tried installing it on different ubuntu virtual machines and computers and I always get the same result.

Do I need to install some specific library or something (which I doubt because the module is listed in standard library https://docs.python.org/3/library/index.html) or is problem elsewhere?


回答1:


This was a bug in the deadsnakes backport of python3.7 specifically for xenial.

During the 3.7 beta period (when the package was imported). The cpython build system used PY_CORE_CFLAGS as a make variable. It was later changed to PY_STDMODULE_CFLAGS. debian ships a patch with their package that adjusts a generated makefile line using a sed expression for that specific variable. Since this was missing it caused the cmath module to build incorrectly.

This has been fixed in this commit

This fix is available in 3.7.0-1+xenial2 (debian version)




回答2:


I installed python3.7 by downloading and installing it using make and cmath started working. It looks like ppa:deadsnakes/ppa repository had missing cmath module.



来源:https://stackoverflow.com/questions/51707435/python-3-7-cmath-module-import-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!