rmislam/PythonSIFT

Trouble getting installed and working

SB2020-eye opened this issue · 4 comments

Hi. I am having trouble getting this working.

I have tried installing and removing and reinstalling various ways. I'm on Windows 10, using Visual Studio Code and Anaconda. I've installed: using Git Bash and the "git clone" command; downloading and unzipping; and with "pip install" from terminal. I've tried this in the folder I usually work from as well as "...\anaconda3\Lib\site-packages."

I have cycled multiple times now through the round of errors you see below.

[Running] python -u "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py"
Traceback (most recent call last):
  File "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py", line 7, in <module>
    import pysift
ModuleNotFoundError: No module named 'pysift'

[Done] exited with code=1 in 1.761 seconds

[Running] python -u "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py"
Traceback (most recent call last):
  File "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py", line 7, in <module>
    import pysift
  File "C:\Users\Scott\anaconda3\lib\site-packages\pysift\__init__.py", line 18, in <module>
    from pysift.core import from_key
  File "C:\Users\Scott\anaconda3\lib\site-packages\pysift\core.py", line 10, in <module>
    from pysift.api import SiftScience
  File "C:\Users\Scott\anaconda3\lib\site-packages\pysift\api.py", line 3, in <module>
    from urlparse import urljoin
ModuleNotFoundError: No module named 'urlparse'

[Done] exited with code=1 in 1.592 seconds

[Running] python -u "c:\Users\Scott\Desktop\Python2\tempCodeRunnerFile.py"
Traceback (most recent call last):
  File "c:\Users\Scott\Desktop\Python2\tempCodeRunnerFile.py", line 1, in <module>
    ur
NameError: name 'ur' is not defined

[Done] exited with code=1 in 0.283 seconds

[Running] python -u "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py"
Traceback (most recent call last):
  File "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py", line 18, in <module>
    kp1, des1 = pysift.computeKeypointsAndDescriptors(img1)
AttributeError: module 'pysift' has no attribute 'computeKeypointsAndDescriptors'

[Done] exited with code=1 in 1.983 seconds

[Running] python -u "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py"
Traceback (most recent call last):
  File "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py", line 18, in <module>
    kp1, des1 = pysift.computeKeypointsAndDescriptors(img1)
AttributeError: module 'pysift' has no attribute 'computeKeypointsAndDescriptors'

[Done] exited with code=1 in 1.579 seconds

[Running] python -u "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py"
Traceback (most recent call last):
  File "c:\Users\Scott\Desktop\Python2\TestTemplateMatchingW.py", line 18, in <module>
    kp1, des1 = pysift.computeKeypointsAndDescriptors(img1)
AttributeError: module 'pysift' has no attribute 'computeKeypointsAndDescriptors'

[Done] exited with code=1 in 1.581 seconds

(For ModuleNotFoundError: No module named 'urlparse', based on websearching and answers like this, I have gone into api.py and changed urlparse to urllib.parse. That leads me to the next error.)

Any help would be appreciated.

HI @SB2020-eye, if you look carefully at the logs you've posted, you see things like this:

"C:\Users\Scott\anaconda3\lib\site-packages\pysift\core.py"

This repo is called PythonSIFT, not pysift. There is no file in my repo called core.py or api.py, and I'm not using the urlparse library at all. You've pip installed some package called pysift, which is someone else's package.

PythonSIFT is not registered on pip, so it's not possible to pip install it.

Just git clone this repo and cd into it, then run python template_matching_demo.py. If python 2 is the default on your system, run python3 template_matching_demo.py. Note that this demo will take a few minutes to run.

Don't pip install anything, or else you'll grab some other package.

My apologies. I kept seeing import pysift with pysift underlined with the warning "unresolved import." I must have tried pip install; and then everything only got worse, obviously. I am brand new at coding ( as you probably can tell!).

I followed your instructions above and ran the demo, in spite of the unresolved import warning. It worked smoothly.

Sorry for the trouble. And thank you very much!

@SB2020-eye No problem, I'm glad to hear you've got it working! No need to apologize. I'm sure your question will help others too.

It's strange you are getting an "unresolved import" warning, though. I will investigate and try to reproduce that when I get a chance.

Hi!
Since Python 3.x, urlparse has been changed to urllib.parse. If you are using anaconda spyder, press ctrl+left_click on pysift, then same (ctrl+lf_cl) on from_key, then same click on SiftScience. There, change the urlparse to urllib.parse and save using ctrl+S. Your code will work most probably. :)