Python
Python, and Solutions.
ModuleNotFoundError: No module named 'xxx'
:
:, Python
Solutions:
- : which python.venv/bin/python
- : pip install xxx
- : __init__.py,
- python -m : python -m mypackage.main
- and ( pip install Pillow import PIL)
:, requirements.txt, New pip install -r requirements.txt
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied
: pip install
:Python,
Solutions:
- : source.venv/bin/activate && pip install xxx
- , : python -m venv.venv
- (Recommended): pip install --user xxx
- sudo pip install, Python
:, Python
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. Package A requires B>=2.0, but you have B 1.5 which is incompatible.
: New
:, pip
Solutions:
- : pip check
- : pip install --upgrade B
- : pip install pipdeptree && pipdeptree -r -p B
- :.venv, New
- uv pip compile
: pip-compile uv pip compile,. New
SyntaxError: Missing parentheses in call to 'print'
: Python 2 Syntax, Python
:Python 2 print Syntax(print "hello"), Python 3
Solutions:
- print "hello" print("hello")
- : 2to3 : 2to3 -w script.py
- : Python 3
- Python : python --version
: Python (pyproject.toml requires-python), ruff Python
RecursionError: maximum recursion depth exceeded
:,
:,
Solutions:
- (base case)
- : while +
- : import sys; sys.setrecursionlimit(10000)()
- __repr__ __str__
- @functools.lru_cache
:, (). Python 1000,