수강생 영어 말하기 No. 1 자세히보기

금융&재테크

파이썬 오류 : No module named 'PyQt5.QAxContainer

승승브라더스 2021. 2. 22. 22:59
728x90

- anaconda / pyCharm 환경

import sys
from PyQt5.QtWidgets import *
from PyQt5.QAxContainer import *

 

- QAxContainer import 에서 에러가 난다.

 

https://stackoverflow.com/questions/56451682/pyqt5-and-anaconda-modulenotfounderror-no-module-named-pyqt5

 

PyQt5 and Anaconda: ModuleNotFoundError: No module named 'PyQt5'

I made a totally new, blank environment in anaconda and activated it. I then did "conda install pyqt5", however when importing modules, like in from PyQt5.QtWidgets import QApplication, QWidget my

stackoverflow.com

- 여기에서 해결점을 찾았다.

 

- 사이트에 있는 해결점 내용

-----------------------------------------------------------------------------------------------------------------------------------

The following worked for me:

  • Install pyqt5 using pip install pyqt5.
  • Then use from PyQt5.QtWidgets import QApplication, QWidget in Python (note the different case!)

UPDATE:

When using virtual environments you have to be sure you are doing all the stuff in the same virtual environment. To do this, first activate your environment, then just use the python command for everything and avoid using the py or pip commands directly.

The following are some steps to help you debugging your problem:

  • First activate your virtual environment. I don't have experience with anaconda, but I assume it's similar to venv or virtualenv (i.e. just calling the corresponding activate script) and you know how to do this.
  • Then:
    • Run python -V to check your Python version.
    • Run python -m pip -V to check the version of PIP. Note that this also prints the location of the pip module. This should be in your virtual environment!
    • Run python -m pip list to see which PIP packages are installed. PyQt5 should be included in this list. If not, run python -m pip install pyqt5 and try again.
    • Run python -m pip show pyqt5 to show information about the pyqt5 module. This also should include a location inside your virtual environment.
    • Run python -c "import PyQt5" to check if the PyQt5 module can be imported. This should print nothing (no ModuleNotFoundError).
    • Run your script using python xyz.py. Don't use the command xyz.py, since in that case the Windows registry determines the "open action", which is likely to run the script using your most recently installed Python version instead of the version from your virtual environment!

-----------------------------------------------------------------------------------------------------------------------------------

 

1. Anaconda Prompt 를 실행한다. ( 윈도우 시작키)

 

2. Anaconda Prompt 콘솔창

# pyqt5 설치
> pip install pyqt5

# 버전체크
> python -V

# pip 버전체크와 경로
> python -m pip -V

# pip 패키지가 설치된 목록
# 목록 중에서 pyqt5 를 확인한다.
> python -m pip list

# 목록중에서 pyqt5 없으면 설치
> python -m pip install pyqt5

# pyqt5 정보를 볼수있고, 경로 확인도 볼수 있다.
> python -m pip show pyqt5

# PyQt5 import 한다. - "여기서 주의점은 대소문자 주의"
> python -c "import PyQt5"

 

짧은 영어지식으로 번역함. ㅎ

728x90