개발/파이썬

matplotlib 오류 - tkinter라는 모듈이 없습니다.

맨날치킨 2022. 11. 30. 15:05
반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

matplotlib error - no module named tkinter

matplotlib 오류 - tkinter라는 모듈이 없습니다.

 문제 내용 

I tried to use the matplotlib package via Pycharm IDE on windows 10. when I run this code:

윈도우 10에서 Pycharm IDE를 통해 matplotlib 패키지를 사용하려고 했습니다. 이 코드를 실행하면:

 

from matplotlib import pyplot

I get the following error:

다음 오류가 발생합니다.

 

ImportError: No module named 'tkinter'

I know that in python 2.x it was called Tkinter, but that is not the problem - I just installed a brand new python 3.5.1.

나는 파이썬 2.x에서 그것이 Tkinter라고 불렸다는 것을 알지만, 그것은 문제가 아니다 - 나는 방금 새로운 파이썬 3.5.1을 설치했다.

 

EDIT: in addition, I also tried to import 'tkinter' and 'Tkinter' - neither of these worked (both returned the error message I mentioned).

편집: 또한 'tkinter'와 'Tkinter'를 가져오려고 했습니다. 둘 다 작동하지 않았습니다(둘 다 제가 언급한 오류 메시지를 반환했습니다).

 

 

 

 높은 점수를 받은 Solution 

For Linux

리눅스용

 

Debian based distros:

데비안 기반 디스트로스:

 

sudo apt-get install python3-tk

RPM based distros:

RPM 기반 디스트로스:

 

sudo yum install python3-tkinter

For windows:

윈도우용:

 

For Windows, I think the problem is you didn't install complete Python package. Since Tkinter should be shipped with Python out of box. See: http://www.tkdocs.com/tutorial/install.html . Good python distributions for Windows can be found by the companies Anaconda or ActiveState.

윈도우의 경우, 문제는 당신이 완전한 파이썬 패키지를 설치하지 않았다는 것이다. Tkinter는 Python과 함께 출고되어야 하기 때문입니다. http://www.tkdocs.com/tutorial/install.html을 참조하십시오. 윈도우용 좋은 파이썬 배포판은 아나콘다 또는 액티브스테이트 회사에서 찾을 수 있습니다.

 

Test the python module

파이썬 모듈 테스트

 

python -c "import tkinter"

p.s. I suggest installing ipython, which provides powerful shell and necessary packages as well.

p.s. 나는 강력한 셸과 필요한 패키지를 제공하는 ipython을 설치하는 것을 제안한다.

 

 

 

 가장 최근 달린 Solution 

For the poor guys like me using python 3.7. You need the python3.7-tk package.

파이썬 3.7을 사용하는 나 같은 불쌍한 사람들을 위해. 당신은 python 3.7-tk 패키지가 필요합니다.

 

sudo apt install python3.7-tk

$ python
Python 3.7.4 (default, Sep  2 2019, 20:44:09)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tkinter'
>>> exit()

Note. python3-tk is installed. But not python3.7-tk.

참고. python3-tk가 설치되어 있습니다. 하지만 파이썬 3.7-tk는 아니다.

 

$ sudo apt install python3.7-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  tix python3.7-tk-dbg
The following NEW packages will be installed:
  python3.7-tk
0 upgraded, 1 newly installed, 0 to remove and 34 not upgraded.
Need to get 143 kB of archives.
After this operation, 534 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main amd64 python3.7-tk amd64 3.7.4-1+xenial2 [143
kB]
Fetched 143 kB in 0s (364 kB/s)
Selecting previously unselected package python3.7-tk:amd64.
(Reading database ... 256375 files and directories currently installed.)
Preparing to unpack .../python3.7-tk_3.7.4-1+xenial2_amd64.deb ...
Unpacking python3.7-tk:amd64 (3.7.4-1+xenial2) ...
Setting up python3.7-tk:amd64 (3.7.4-1+xenial2) ...

After installing it, all good.

설치 후에는 모두 좋습니다.

 

$ python3
Python 3.7.4 (default, Sep  2 2019, 20:44:09)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> exit()

 

 

출처 : https://stackoverflow.com/questions/36327134/matplotlib-error-no-module-named-tkinter

반응형