Python

Python, and Solutions.

ModuleNotFoundError: No module named 'xxx'

:

:, Python

Solutions:

  1. : which python.venv/bin/python
  2. : pip install xxx
  3. : __init__.py,
  4. python -m : python -m mypackage.main
  5. 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:

  1. : source.venv/bin/activate && pip install xxx
  2. , : python -m venv.venv
  3. (Recommended): pip install --user xxx
  4. 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:

  1. : pip check
  2. : pip install --upgrade B
  3. : pip install pipdeptree && pipdeptree -r -p B
  4. :.venv, New
  5. 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:

  1. print "hello" print("hello")
  2. : 2to3 : 2to3 -w script.py
  3. : Python 3
  4. Python : python --version

: Python (pyproject.toml requires-python), ruff Python

RecursionError: maximum recursion depth exceeded

:,

:,

Solutions:

  1. (base case)
  2. : while +
  3. : import sys; sys.setrecursionlimit(10000)()
  4. __repr__ __str__
  5. @functools.lru_cache

:, (). Python 1000,