close

[Solved] PATH issue with pytest ‘ImportError: No module named YadaYadaYada’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error PATH issue with pytest ‘ImportError: No module named YadaYadaYada’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How PATH issue with pytest ‘ImportError: No module named YadaYadaYada’ Error Occurs?

Today I get the following error PATH issue with pytest ‘ImportError: No module named YadaYadaYada’ in python.

How To Solve PATH issue with pytest ‘ImportError: No module named YadaYadaYada’ Error ?

  1. How To Solve PATH issue with pytest 'ImportError: No module named YadaYadaYada' Error ?

    To Solve PATH issue with pytest 'ImportError: No module named YadaYadaYada' Error Yes, the source folder is not in Python's path if you cd to the tests directory.

  2. PATH issue with pytest 'ImportError: No module named YadaYadaYada'

    To Solve PATH issue with pytest 'ImportError: No module named YadaYadaYada' Error Yes, the source folder is not in Python's path if you cd to the tests directory.

Solution 1

I had the same problem in Flask.

When I added:

__init__.py

to tests folder, problem disappeared 🙂

Probably application couldn’t recognize folder tests as module

Solution 2

Yes, the source folder is not in Python’s path if you cd to the tests directory.

You have 2 choices:

  1. Add the path manually to the test files, something like this:import sys, os myPath = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, myPath + '/../')
  2. Run the tests with the env var PYTHONPATH=../.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read