Python 3.7 cmath 模块导入错误 [英] Python 3.7 cmath module import error

查看:47
本文介绍了Python 3.7 cmath 模块导入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ppa:deadsnakes/ppa 存储库在 ubuntu 上安装了 python3.7.

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

当我尝试跑步时

import cmath

在 python shell 中它失败并显示消息:

in python shell it fails with message:

ModuleNotFoundError: No module named 'cmath'

我没有在 python3.7 更新日志中找到任何关于这个库或任何内容的弃用信息.它在 python 3.5 和 2.7 中运行良好.我尝试在不同的 ubuntu 虚拟机和计算机上安装它,但总是得到相同的结果.

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.

我是否需要安装一些特定的库或其他东西(我对此表示怀疑,因为该模块列在标准库中 https://docs.python.org/3/library/index.html) 还是其他地方有问题?

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?

推荐答案

这是 python3.7 的 deadsnakes backport 中的一个 bug,特别是 for xenial.

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

在 3.7 测试版期间(导入包时).cpython 构建系统使用 PY_CORE_CFLAGS 作为 make 变量.后来改为PY_STDMODULE_CFLAGS.debian 随其软件包提供了一个补丁,该补丁使用该特定变量的 sed 表达式调整生成的 makefile 行.由于缺少它导致 cmath 模块构建错误.

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.

这已在此提交

此修复在 3.7.0-1+xenial2(debian 版本)中可用

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

这篇关于Python 3.7 cmath 模块导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆