module ‘pip’ has no attribute ‘pep425tags’

To print the list of compatible tags with current versions of pip : $ path/to/pythonX.Y -m pip debug –verbose The pip debug subcommand is available since v19.2 (July 2019). To get the list of compatible tags from Python code, I recommend using the packaging library and its packaging.tags.sys_tags() function: import packaging.tags tags = packaging.tags.sys_tags() print(‘\n’.join([f'{tag.interpreter}-{tag.abi}-{tag.platform}’ … Read more

Relative imports in Python

Nevermind, I solved it: src/ main.py mod/ __init__.py components/ __init__.py expander.py language_id.py utilities/ __init__.py functions.py main.py then refers to the subpackages as: from mod.components.expander import * from mod.utilities.functions import * expander.py and language_id.py have access to functions.py with: from ..utilities.functions import * But the interesting thing is that I had a text file inside the … Read more

“pip install –editable ./” vs “python setup.py develop”

Try to avoid calling setup.py directly, it will not properly tell pip that you’ve installed your package. With pip install -e: For local projects, the “SomeProject.egg-info” directory is created relative to the project path. This is one advantage over just using setup.py develop, which creates the “egg-info” directly relative the current working directory. More: docs … Read more

Using pytest with a src layer

Recommended approach for pytest>=7: use the pythonpath setting Recently, pytest has added a new core plugin that supports sys.path modifications via the pythonpath configuration value. The solution is thus much simpler now and doesn’t require any workarounds anymore: pyproject.toml example: [tool.pytest.ini_options] pythonpath = [ “src” ] pytest.ini example: [pytest] pythonpath = src The path entries … Read more

What is setup.py?

setup.py is a python file, the presence of which is an indication that the module/package you are about to install has likely been packaged and distributed with Distutils, which is the standard for distributing Python Modules. This allows you to easily install Python packages. Often it’s enough to write: $ pip install . pip will … Read more