My cloned app from git repository need module indexer
in the app. So I install indexer
using python3
:
python3 -m pip install indexer //this is equal to pip3 install indexer*
However it generates this error:
I search it and I got an answer from this stackoverflow question .
So it seems it is a problem with a different syntax from a different python version.
I tried to install it with python2
and it works. But since I use python3
to run it, I search another indexer
module that compatible in python3
and I found python3-lzo-indexer and tried to install it. But when I run it with python3
, it still missing module indexer
.
How can I install indexer with python3
?
Someone already asked on stackoverflow here but still there is no solution
*) I used the command above since I install a dual version of python ( python2
and python3
) on my machine. Even though that is not the case.
Reinstall Python and try again. I tried to reproduce this error.
Trying to install indexer:
Collecting indexer
Downloading indexer-0.6.2.tar.gz (14 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\fatalcoder524\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\fatalcoder524\\AppData\\Local\\Temp\\pip-install-btasoark\\indexer\\setup.py'"'"'; __file__='"'"'C:\\Users\\fatalcoder524\\AppData\\Local\\Temp\\pip-install-btasoark\\indexer\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\fatalcoder524\AppData\Local\Temp\pip-install-btasoark\indexer\pip-egg-info'
cwd: C:\Users\fatalcoder524\AppData\Local\Temp\pip-install-btasoark\indexer\
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\fatalcoder524\AppData\Local\Temp\pip-install-btasoark\indexer\setup.py", line 107
except OSError, ex:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Trying to install python3-lzo-indexer:
Collecting python3-lzo-indexer
Downloading python3_lzo_indexer-0.3.0-py2.py3-none-any.whl (6.6 kB)
Requirement already satisfied: click==7.0 in c:\users\fatalcoder524\appdata\local\programs\python\python37\lib\site-packages (from python3-lzo-indexer) (7.0)
Installing collected packages: python3-lzo-indexer
Successfully installed python3-lzo-indexer-0.3.0
Trying to use indexer using python -m "import lzo_indexer"
:
C:\Users\fatalcoder524\AppData\Local\Programs\Python\Python37\python.exe: No module named import lzo_indexer
Trying to execute in python interpreter:
Python 3.7.0b3 (v3.7.0b3:4e7efa9c6f, Mar 29 2018, 18:42:04) [MSC v.1913 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import lzo_indexer
>>> dir(lzo_indexer)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'get_lzo_blocks', 'index_lzo_file', 'indexer']
Running python3 -m pip install indexer
gives this error.
Collecting indexer
Downloading https://files.pythonhosted.org/packages/c7/2f/49ea001ccc81502fe790c6077ca0cf9c4dc98ce160e1b1225a8c881b53b1/indexer-0.6.2.tar.gz
ERROR: Command errored out with exit status 1:
command: 'c:\users\mike\projects\test\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Mike\\AppData\\Local\\Temp\\pip-install-o8rly6_7\\indexer\\setup.py'"'"'; __file__='"'"'C:\\Users\\Mike\\AppData\\Local\\Temp\\pip-install-o8rly6_7\\indexer\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: C:\Users\Mike\AppData\Local\Temp\pip-install-o8rly6_7\indexer\
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Mike\AppData\Local\Temp\pip-install-o8rly6_7\indexer\setup.py", line 107
except OSError, ex:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The Downloading
line shows where it's being downloaded from so you can just download the tar.gz
from there and unpack it. In the base folder you should see a setup.py
file. THe Traceback from the previous error gives you a good hint on where the error occurred. This line
except OSError, ex:
is invalid python 3 syntax and translates to
except OSError as ex:
in python 3.
So you need to change lines 107
and 116
to that as they'll both have the same syntax error. Additionally, there's an import which needs to be changed. Change line 14
from
from os.path import isdir, exists, join, walk
to this
from os.path import isdir, exists, join
and add another line beneath it like this
from os import walk
In python 3 walk
is called from directly inside the os
module.
When that is saved you can just run python3 -m pip install <path to base folder>
where <path to base folder>
is the folder that setup.py
is in.
DISCLAIMER:
This will only get you part of the way as this package is intended for python 2.
After installing it, I can see in Lib\site-packages\indexer\postgres8_indexer.py
, Lib\site-packages\indexer\search.py
, and probably other places there are a few instances of the python 2 print
statement. These can obviously be changed as you come across them but there are most likely other more subtle syntax differences.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.