简体   繁体   English

Pip 在 Python3 中安装索引器错误 Windows 10

[英]Pip install indexer error in Python3 Windows 10

My cloned app from git repository need module indexer in the app.我从 git 存储库克隆的应用程序需要应用程序中的模块indexer So I install indexer using python3 :所以我使用python3安装indexer

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 .我搜索它,我从这个 stackoverflow 问题中得到了答案。

So it seems it is a problem with a different syntax from a different python version.因此,与不同的 python 版本不同的语法似乎是一个问题。

I tried to install it with python2 and it works.我尝试使用python2安装它并且它可以工作。 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.但由于我使用python3运行它,我搜索了另一个与python3兼容的indexer模块,我找到了python3-lzo-indexer并尝试安装它。 But when I run it with python3 , it still missing module indexer .但是当我用python3运行它时,它仍然缺少模块indexer

How can I install indexer with python3 ?如何使用python3安装索引器?

Someone already asked on stackoverflow here but still there is no solution有人已经在这里问过stackoverflow,但仍然没有解决方案

*) I used the command above since I install a dual version of python ( python2 and python3 ) on my machine. *) 我使用了上面的命令,因为我在我的机器上安装了 python( python2python3 )的双版本。 Even though that is not the case.即使情况并非如此。

Reinstall Python and try again.重新安装 Python 并重试。 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:尝试安装 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" :尝试使用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 解释器中执行:

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.运行python3 -m pip install indexer会出现此错误。

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. Downloading行显示从哪里下载它,因此您可以从那里下载tar.gz并解压缩它。 In the base folder you should see a setup.py file.在基本文件夹中,您应该会看到一个setup.py文件。 THe Traceback from the previous error gives you a good hint on where the error occurred.上一个错误的 Traceback 可以很好地提示您错误发生的位置。 This line这条线

except OSError, ex:

is invalid python 3 syntax and translates to是无效的 python 3 语法并转换为

except OSError as ex:

in python 3.在 python 3。

So you need to change lines 107 and 116 to that as they'll both have the same syntax error.因此,您需要将第107行和116行更改为该行,因为它们都有相同的语法错误。 Additionally, there's an import which needs to be changed.此外,还有一个需要更改的导入。 Change line 14 from将第14行从

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.在 python 3 walk是从os模块内部直接调用的。

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.保存后,您只需运行python3 -m pip install <path to base folder>其中<path to base folder>setup.py所在的文件夹。

DISCLAIMER:免责声明:

This will only get you part of the way as this package is intended for python 2.这只会让您部分获得成功,因为此 package 适用于 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.安装后,我可以在Lib\site-packages\indexer\postgres8_indexer.pyLib\site-packages\indexer\search.py 和其他地方看到 python 2 print语句的一些实例。 These can obviously be changed as you come across them but there are most likely other more subtle syntax differences.当您遇到它们时,这些显然可以更改,但很可能还有其他更细微的语法差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM