skip to Main Content

I’ve created a virtual environment of Python3.9 with Pycharm but when I try to install the packages in requirements, I get this error:

Error: Traceback (most recent call last):

  File "/snap/pycharm-professional/401/plugins/python/helpers/packaging_tool.py", line 85, in run_pip
    runpy.run_module(module_name, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/__main__.py", line 22, in <module>
    from pip._internal.cli.main import main as _main
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
    from pip._internal.build_env import get_runnable_pip
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/build_env.py", line 19, in <module>
    from pip._internal.cli.spinners import open_spinner
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/cli/spinners.py", line 9, in <module>
    from pip._internal.utils.logging import get_indentation
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 29, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 41, in <module>
    from pip._internal.locations import get_major_minor_version
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/locations/__init__.py", line 66, in <module>
    from . import _distutils
  File "/home/my_user/Documents/my_project/venv/lib/python3.9/site-packages/pip/_internal/locations/_distutils.py", line 20, in <module>
    from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils.cmd'

I tried installing sudo apt install python3.9-distutils but I get:

E: Unable to locate package python3.9-distutils
E: Couldn't find any package by glob 'python3.9-distutils'

Any idea?

2

Answers


  1. Chosen as BEST ANSWER

    Trying to solve the last issue, it solves everything. To do that, I ran:

    sudo add-apt-repository ppa:deadsnakes/ppa
    sudo apt update
    

    to update apt with old versions of python and, particularly, of python3.9-dev and python3.9-venv. After that, I ran:

    sudo apt install python3.9 python3.9-venv python3.9-dev
    

    I created again the repository, and I could install the requirements.


  2. pip install distulus
    .venvScriptsactivate
    source .venv/bin/activate
    Ensure that you are using the correct Python version where the module is installed. Sometimes, you might have multiple Python installations, and the module might be installed in one version but not in another
    Double-check the spelling of the module name. It’s possible that there might be a typo in your import statement.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search