0

I have installed pytest successfully,but import error occurs "ModuleNotFoundError: No module named 'pytest'".I can see pytest in my finder but it not in the "python3 -m pip list".How can I solve it?

HelendeMacBook-Pro:bin helendai$ pip3 install pytest
Collecting pytest
  Using cached pytest-5.4.1-py3-none-any.whl (246 kB)
Requirement already satisfied: more-itertools>=4.0.0 in /usr/local/lib/python3.6/site-packages (from pytest) (8.2.0)
Requirement already satisfied: packaging in /usr/local/lib/python3.6/site-packages (from pytest) (20.3)
Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.6/site-packages (from pytest) (19.3.0)
Requirement already satisfied: pluggy<1.0,>=0.12 in /usr/local/lib/python3.6/site-packages (from pytest) (0.13.1)
Requirement already satisfied: py>=1.5.0 in /usr/local/lib/python3.6/site-packages (from pytest) (1.8.1)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/site-packages (from pytest) (0.1.9)
Requirement already satisfied: importlib-metadata>=0.12; python_version < "3.8" in /usr/local/lib/python3.6/site-packages (from pytest) (1.6.0)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.6/site-packages (from packaging->pytest) (2.4.7)
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from packaging->pytest) (1.14.0)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/site-packages (from importlib-metadata>=0.12; python_version < "3.8"->pytest) (3.1.0)
Installing collected packages: pytest
Successfully installed pytest-5.4.1
HelendeMacBook-Pro:bin helendai$ python3 -m pip list
Package      Version   
------------ ----------
certifi      2019.11.28
cffi         1.14.0    
chardet      3.0.4     
cryptography 2.8       
idna         2.9       
pip          20.0.2    
pycparser    2.20      
pyOpenSSL    19.1.0    
PyYAML       5.3       
requests     2.23.0    
setuptools   41.2.0    
six          1.14.0    
urllib3      1.25.8    
HelendeMacBook-Pro:bin helendai$ python3
Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pytest'

enter image description here

Helen Dai
  • 9
  • 1
  • 2
  • Does this answer your question? [ModuleNotFoundError: No module named 'pytest'](https://stackoverflow.com/questions/55652866/modulenotfounderror-no-module-named-pytest) – Joshua Varghese Apr 07 '20 at 10:31

1 Answers1

0

perhaps you had installed multiple python on your computer, because the install logs show pytest is installed on python 3.6, but the python shell show your python version is 3.8.2

Yao Pan
  • 524
  • 9
  • 26