3

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 Answers3

2
  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
arun n a
  • 684
  • 9
  • 26
1

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
Zichzheng
  • 1,090
  • 7
  • 25
0

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

LittleCoder
  • 391
  • 1
  • 13
  • Please delete your answer. It is wrong. – arun n a Jun 30 '21 at 01:15
  • No, it's true. "Pip is for python version less than 3. and pip3 is used when you want to install packages for python version 3 or higher." source = https://python-forum.io/thread-12792.html. If you are on a mac, pip comes pre-installed with Python 2.7. Pip3 is the Python3 version of pip. "If you just use pip, then only the python2.7 version will be installed. You have to use pip3 for it to be installed on Python3." source = https://www.quora.com/What-is-difference-between-pip-and-pip3 – LittleCoder Jun 30 '21 at 06:39
  • Yes. I am using mac and pip is working I upgraded to python3. From his error message, it is clear that it is not an issue with pip/pip3. – arun n a Jun 30 '21 at 07:03
  • Ok sorry so I don't know. I've tried to install pycodestyle on my Mac using pip3, and there is no problem. If you've upgraded ```pip``` to python3, as you said, the problem isn't here. – LittleCoder Jun 30 '21 at 07:08