반응형
python -m tt.py
위와 같이 명령어 실행시 has no attribute '__path__' 에러 발생 할수 있다
python -m tt --> py를 제거하고 실행하면 된다.
---
There are two ways you can run a Python 3 script.
- python fibo.py: The argument is the name of the .py file. Dots are part of the filename.
- python -m fibo: The argument is the name of a Python module, without .py. Dots indicate packages; fibo.py means "the module py in the package fibo."
This is a small distinction for a simple script like yours. But for something bigger or more complex, it has an important effect on the behavior of the import statement:
- The first form will cause import to search the directory where the .py file lives (and then search various other places including the standard library; see sys.path for a full list).
- The second form will make import search the current directory (and then various other places).
For this reason, under Python 3, the second form is required for most setups which involve packages (rather than just loose modules in a directory), since the parent package of the script may not be importable under the first form, which can cause things to break.
반응형
'IT기술 관련 > 파이썬_루비 등 언어' 카테고리의 다른 글
파이썬 에러 ModuleNotFoundError: No module named ‘win32api’ 해결 방법 (0) | 2023.03.14 |
---|---|
Python whl 파일 설치 방법 (0) | 2019.11.13 |
파이썬 requests 라이브러리를 활용한 웹 취약점 점검 (0) | 2017.02.02 |
[PYTHON 3] Tutorials 24. 웹 크롤러(like Google) 만들기 1 - How to build a web crawler (1) | 2017.02.02 |
[파이썬] typeError: isinstance() arg 2 must be a type or tuple of types 에러 해결 (0) | 2016.09.21 |