"ModuleNotFoundError: No module named 'pycodestyle'"

5k Views Asked by At

I have installed pycodestyle on my mac in the same path using

pip install pycodestyle

but when I check for its version I get-

    "pycodestyle" --version
Traceback (most recent call last):
  File "/Users/shashwatkhilar/tools/bin/pycodestyle", line 6, in <module>
    from pycodestyle import _main
ModuleNotFoundError: No module named 'pycodestyle'
3

There are 3 best solutions below

0
On BEST ANSWER
  1. Create a project directory demo
  2. change directory to the project directory
  3. create a virtual environment myenv
  4. Activate the virtual environment.
  5. Install pycodestyle
mkdir demo
cd demo
python3 -m venv myen
source myenv/bin/activate
pip install pycodestyle

Check whether it is installed or not using any of these commands

pip freeze

or

pycodestyle --version
0
On

Since you are using mac. I think you should have at least two versions of python, and this pip install is with another python. You can try

pip3 install pycodestyle

if that's not working try to find the correct version you want to use and set alias with

alias python=/usr/local/bin/python3
4
On

On Mac, pip refers to an older version of Python. If You want to use Python 3, use the pip3 command.