1

I am working on a project, structured like this:

myproject
│ 
├──__init__.py
├──__main__.py
│ 
├── requests
│   ├── __init__.py
│   ├── test.py

I pip-installed my project as a package into venv I am working in with setuptools(described here. [Sibling package imports See the answer titled "Tired on sys.path hacks?")

In every module of my project I use absolute imports like this:

from myproject.requests import test

The problem is I also use requests library (https://2.python-requests.org/en/master/). It is also installed in venv. When importing for example requesets.exceptions.ConnectionError from test.py, everything works as intended But when i try to do the same from __main__.py, it imports myproject.requests submodule instead.(which I already sucesfuly import like this: from myproject import requests How do I fix it, without renaming requests submodule?

Hello
  • 57
  • 1
  • 6

0 Answers0