-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
ModuleNotFoundError: No module named 'xxx' #2287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually The standard procedure is to use a virtual environment (which travis already sets up for you automatically) and install your project in development mode: install:
- pip install -r requirements.txt
- pip install -e . Then both HTH, I will close this for now to not let the issue lingering open, but feel to follow up with further questions. |
@nicoddemus Thank you for the informative explanation. Consistent behaviour or not, I now understand what is happening, so no further questions. |
Hi... I have python 2.7 installed in my system. I installed pytest, that is compatible with this version of python. However, when I tried writing tests, my code keeps crying for compile errors. Also, when I try the command "pytest --version", I see this error: Although, the command "which pytest" gives me this result: Can someone please help me with this? |
@namratha-bharadwaj your error is unrelated and indicates a completely broken pytest installation |
@namratha-bharadwaj just to complement what @RonnyPfannschmidt said, the recommended practice is using a virtualenv instead and install pytest and your project there. |
Empty script (no test, just an import statement) that has any one of these
But on these it works. Same process.
atomicwrites |
Why am I also seeing this strange behavior too. This is my sample test project https://github.com/scheung38/travelex-flask-aws-docker/ It was working before once inside venv $HOME/PyCharmProject/flask-aws-docker> $ py.test -v but worked several times, but now it is also: ============================================================================= test session starts ============================================================================= =================================================================================== ERRORS ==================================================================================== =================================================================================== ERRORS ==================================================================================== =================================================================================== ERRORS ==================================================================================== |
@nicoddemus Thanks for the solution.
|
The issue might be having pytest installed system wide: |
I've created a virtual environment using the command pip install -e . and the problem was fixed. Thanks! |
I'm having this same issue within a venv managed by Poetry. |
I'm using Python 3.6 and pytest 3.0.6, on Windows and Linux.
I have noticed a strange issue. Here is a test project which I used to reproduce the problem: https://github.com/mloskot/python-package/
Go to root folder of the project
Run
pytest
command and observe the error (see failing Travis CI build 1):python -m pytest
command and observe successful run, with all modules under test being found (see Travis CI build 2)AFAIK, both commands are equivalent.
The only bug report related to
ModuleNotFoundError
and Python 3.6 I found is #2132 but I'm not sure if this is related in any way.The text was updated successfully, but these errors were encountered: