1

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?

miloslu
  • 434
  • 7
  • 12
  • 1
    interestingly the [docs](https://docs.python.org/3.7/library/cmath.html) say: `This module is always available.` so i'm guessing its an issue with the repository you're using – James Kent Aug 06 '18 at 12:28
  • 1
    Using Pyenv I have the cmath module installed in 3.7 so I guess the issue comes from the repository. Side note: If you use multiple versions of python on the same machine taking a look at tools like Pyenv may make your job easier – Plopp Aug 06 '18 at 12:32

2 Answers2

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)

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
0

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.

miloslu
  • 434
  • 7
  • 12