Cannot import Decimal module

前端 未结 2 1367
眼角桃花
眼角桃花 2021-01-25 22:40

I am trying to do some simple decimal math to practice with the Tkinter GUI, but for some reason I cannot import Decimal:

>>> from decimal import Decima         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 23:25

    I was having the same issue of Python 3+ not being able to import Decimal. Even some external libraries, like pygal, would not install because the system could not access Decimal and decimal library.

    I found accidentally in another site that "there maybe another decimal.py file in your system, shadowing on the decimal library".

    I checked and found out that I had named a test file (while I was learning Python) as decimal.py and after I renamed this to decimaltest.py everything is working perfect.

    Check if you have done the same or you have any similar wrongly named file in your system.

提交回复
热议问题