Skip to content

No module named 'imutils' after pip install #24

Closed

Description

@benstadin

I just followed this guide here to install OpenCV: http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/

And then followed this guide here: http://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/

I've pip-installed imutils, but keep getting the error below.

sudo pip install imutils
...
Collecting imutils
  Downloading imutils-0.4.2.tar.gz
Installing collected packages: imutils
  Running setup.py install for imutils ... done
Successfully installed imutils-0.4.2
hdmih0445m:shape-detection bstadin$ 

The install seems to be ok, trying to reinstall imutils gives:

Requirement already satisfied: imutils in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

Running a script importing imutils:

python3 detect_shapes.py --image /Users/bstadin/Downloads/image.png
...
Traceback (most recent call last):
  File "detect_shapes.py", line 7, in <module>
    import imutils
ModuleNotFoundError: No module named 'imutils'

Activity

  1. saschwarz commented on Apr 12, 2017

    @saschwarz

    It looks like you pip installed imutils using python2's pip and so that's why python3 can't import it. You might try: sudo pip3 install imutils

  2. FariborzN commented on Oct 23, 2017

    @FariborzN

    @for imutlis package
    if you got error
    uninstall package withsudo pip3 uninstall imutils
    and then you see this
    Uninstalling imutils-0.4.3:
    /usr/local/bin/range-detector
    /usr/local/lib/python3.5/dist-packages/imutils-0.4.3.dist-info/DESCRIPTION.rst
    /usr/local/lib/python3.5/dist-packages/imutils-0.4.3.dist-info/INSTALLER
    /usr/local/lib/python3.5/dist-packages/imutils-0.4.3.dist-info/METADATA
    /usr/local/lib/python3.5/dist-packages/imutils-0.4.3.dist-info/RECORD
    /usr/local/lib/python3.5/dist-packages/imutils-0.4.3.dist-info/WHEEL
    /usr/local/lib/python3.5/dist-packages/imutils-0.4.3.dist-info/metadata.json
    /usr/local/lib/python3.5/dist-packages/imutils-0.4.3.dist-info/top_level.txt
    /usr/local/lib/python3.5/dist-packages/imutils/init.py
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/init.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/contours.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/convenience.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/encodings.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/meta.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/object_detection.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/paths.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/pycache/perspective.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/contours.py
    /usr/local/lib/python3.5/dist-packages/imutils/convenience.py
    /usr/local/lib/python3.5/dist-packages/imutils/encodings.py
    /usr/local/lib/python3.5/dist-packages/imutils/face_utils/init.py
    /usr/local/lib/python3.5/dist-packages/imutils/face_utils/pycache/init.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/face_utils/pycache/facealigner.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/face_utils/pycache/helpers.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/face_utils/facealigner.py
    /usr/local/lib/python3.5/dist-packages/imutils/face_utils/helpers.py
    /usr/local/lib/python3.5/dist-packages/imutils/feature/init.py
    /usr/local/lib/python3.5/dist-packages/imutils/feature/pycache/init.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/feature/pycache/factories.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/feature/pycache/gftt.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/feature/pycache/helpers.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/feature/factories.py
    /usr/local/lib/python3.5/dist-packages/imutils/feature/gftt.py
    /usr/local/lib/python3.5/dist-packages/imutils/feature/helpers.py
    /usr/local/lib/python3.5/dist-packages/imutils/io/init.py
    /usr/local/lib/python3.5/dist-packages/imutils/io/pycache/init.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/io/pycache/tempfile.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/io/tempfile.py
    /usr/local/lib/python3.5/dist-packages/imutils/meta.py
    /usr/local/lib/python3.5/dist-packages/imutils/object_detection.py
    /usr/local/lib/python3.5/dist-packages/imutils/paths.py
    /usr/local/lib/python3.5/dist-packages/imutils/perspective.py
    /usr/local/lib/python3.5/dist-packages/imutils/video/init.py
    /usr/local/lib/python3.5/dist-packages/imutils/video/pycache/init.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/video/pycache/count_frames.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/video/pycache/filevideostream.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/video/pycache/fps.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/video/pycache/pivideostream.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/video/pycache/videostream.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/video/pycache/webcamvideostream.cpython-35.pyc
    /usr/local/lib/python3.5/dist-packages/imutils/video/count_frames.py
    /usr/local/lib/python3.5/dist-packages/imutils/video/filevideostream.py
    /usr/local/lib/python3.5/dist-packages/imutils/video/fps.py
    /usr/local/lib/python3.5/dist-packages/imutils/video/pivideostream.py
    /usr/local/lib/python3.5/dist-packages/imutils/video/videostream.py
    /usr/local/lib/python3.5/dist-packages/imutils/video/webcamvideostream.py

    and then ask you?

    Proceed (y/n)?
    answer yes(use Y key)
    and then use sudo pip3 install --upgrade imutils
    if you use python2 use pip insted pip3 for instalation and unistallation

  3. radhikatv commented on Jan 22, 2018

    @radhikatv

    I am trying to install imutils using :
    conda install -c mlgill imutils

    and I get the below error

    Solving environment: failed

    UnsatisfiableError: The following specifications were found to be in conflict:

    • imutils
    • ruamel_yaml
  4. jrosebr1 commented on Jan 22, 2018

    @jrosebr1
    Contributor

    The imutils library is a non-conda package. You need to install via pip. See this thread for more details: #36

  5. radhikatv commented on Jan 23, 2018

    @radhikatv
  6. jrosebr1 commented on Jan 23, 2018

    @jrosebr1
    Contributor

    Try setting the Project Interpreter from your PyCharm settings to point to your conda install or associated Python virtual environment.

  7. iamjadhav commented on Jan 30, 2018

    @iamjadhav

    Hey @jrosebr1 . I am using Anaconda(spyder) for image processing and was trying the ball tracking blog from your site. I wanted to install imutils and used the command pip install imutils. I can see imutils in the list but when i try to run the program again , it shows 'no module found' again. Please me help with this.

  8. jrosebr1 commented on Jan 30, 2018

    @jrosebr1
    Contributor

    Are you referring to the Spyder IDE? You'll need to set the project interpreter for Spyder. I don't use Spyder so I'm not sure how to do this, but for PyCharm take a look at this tutorial:

    https://www.pyimagesearch.com/2015/08/17/the-perfect-computer-vision-environment-pycharm-opencv-and-python-virtual-environments/

    Personally, I like executing my scripts via command line. If you're having problems executing via your IDE you can always revert to terminal.

  9. iamjadhav commented on Feb 2, 2018

    @iamjadhav

    Thanks ! Will use Pycharm now.

  10. ANTZ314 commented on Aug 15, 2018

    @ANTZ314

    Hey guys I tried the uninstall method and re-installed from both within and outside the (cv) environment and still getting the "no module named imutils" error?
    Any suggestions. I've never had this problem previously.

  11. jrosebr1 commented on Aug 15, 2018

    @jrosebr1
    Contributor

    Hey @ANTZ314 -- my guess is that you may have accidentally installed and uninstalled (perhaps multiple times over) the imutils library from your system Python install and your Python virtual environment. Here's the fool-proof method:

    $ workon cv
    $ pip install imutils
    $ python
    >>> import imutils
    
  12. HongChow commented on Aug 30, 2018

    @HongChow

    How to fix that? @jrosebr1

  13. jrosebr1 commented on Aug 30, 2018

    @jrosebr1
    Contributor

    @HongChow I've answered the question many times in the thread. You'll need to be more specific regarding the exact error you are getting, operating system, and Python environment.

  14. KingfaLuis commented on Sep 15, 2018

    @KingfaLuis

    pip install imutils

  15. markp64 commented on Sep 16, 2018

    @markp64

    I ran $ sudo pip install imutils
    then $ python
    python 3.5.2

    import imutils
    ImportError: No module names 'imutils'

    if run $ sudo python
    Python 2.7.12

    import imutils
    (imports ok)

    I had installed imutils in Python2.7 (sudo pip install imutils) and was trying to use it in Python3 (thinking I was in Python2 - PEBKAC)

    Firstly, I didn't notice that I was running python3 and then python2 when using sudo.
    Secondly, I had an alias entry in my .bashrc file causing the confusion: alias python='/usr/bin/python3'
    Thirdly, have to be aware when using sudo, that it runs in a different user environment. (Try $ env, then $ sudo env ). sudo is not just a security override.

  16. elgarmi09gt commented on Dec 15, 2018

    @elgarmi09gt

    Hi
    Note : The version of python is determine in python Path but version of pip is in python path + Scripts
    So if you like to install module by pip configure your environment variable and make the right way of pip you like to use and install your module with pip
    Tks

  17. ellensp commented on Dec 26, 2018

    @ellensp

    you need to reactivate the virtual environment. ie do the following commands
    source ~/.profile
    workon cv
    cd Smart-Security-Camera
    python main.py

  18. ayanasser commented on Apr 11, 2019

    @ayanasser

    Hi all ,

    It's installed on python3 perfectly ,
    but when i installed it on python2 it gave me this error

    The directory '/home/biohelwan/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Requirement already satisfied: imutils in /usr/local/lib/python3.5/dist-packages (0.5.2)

  19. jrosebr1 commented on Apr 15, 2019

    @jrosebr1
    Contributor

    Delete your .cache directory first and then retry:

    $ rm -rf ~/.cache

  20. Mathew3000 commented on Jun 5, 2019

    @Mathew3000

    Hey, my solution was to install imutils without sudo. I hope it helps someone.

  21. lamoboos223 commented on Jul 12, 2019

    @lamoboos223
    1. sudo pip uninstall imutils
    2. sudo pip install imutils
    3. python3
    4. import imutils
    5. if there is no error enter exit()

    and congrats it works perfectly

  22. ajaytomgeorge commented on Aug 2, 2019

    @ajaytomgeorge

    most probably it is getting installed in global and not in local. Check if imutils is in this folder C:\Program Files\Python37\Lib\site-packages

    copy paste imutils and imutils-0.5.2.dist-info folder in your local C:\usersid\AppData\Roaming\Python\Python37\site-packages

    NB:AppData folder is hidden

    or pip install --user imutils

  23. rvdrupal commented on Feb 19, 2020

    @rvdrupal

    try this >> conda install -c conda-forge imutils

  24. amrfodd commented on Oct 11, 2020

    @amrfodd

    import pip
    pip.main(['install', 'imutils'])

    in Jupyter Notebook

  25. TrabelsiRim commented on Nov 26, 2020

    @TrabelsiRim

    Python 2.7

    pip install imutils
    or
    sudo pip install imutils (Raspberry)

    Python 3

    pip3 install imutils
    or
    sudo pip3 install imutils (Raspberry)

  26. SalmanCode commented on Jan 1, 2021

    @SalmanCode

    Hey guys I tried the uninstall method and re-installed from both within and outside the (cv) environment and still getting the "no module named imutils" error?
    Any suggestions. I've never had this problem previously.

    Hello, did it finaly worked for you. I am having the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions