问题描述
我正在使用 Windows 10 ,并且要安装 openalpr 并将库导入到 python .
I am using Windows 10 and I want to install openalpr and import the library to python.
但是,下载了预编译的Windows二进制文件后,我不知道如何在python中导入alpr
However, after downloaded the Pre-compiled Windows binaries, I dont know how ti import alpr in python
我遵循 OpenAlpr
我在此处下载了 openalpr-2.3.0-win-64bit.zip 并解压缩.
I downloaded the openalpr-2.3.0-win-64bit.zip here and unzipped it.
然后,我可以在命令行中运行alpr
,但不能导入它.
Afterwards, I can run alpr
in command line but I cannot import it.
任何人都可以教我如何在python中导入Openalpr.谢谢.
Can anyone teach me how I can import Openalpr in python. Thank you.
推荐答案
下载二进制发行版后,导航至python
子目录并运行python setup.py
.这会将OpenALPR作为软件包安装,因此您可以从任何地方导入它,而不仅仅是从ALPR的目录中导入.
When you've downloaded the binary distribution, navigate to python
subdirectory and run python setup.py
. This would install OpenALPR as package, so then you would be able to import it from anywhere, not just from ALPR's directory.
说明:为了可导入,它要求您尝试导入的软件包为其他软件包:
Explaination:To be importable, it requires that the package you're trying to import been else:
- 在当前目录中,运行
python
的位置 - 通过
PYTHONPATH
环境变量指定 - 标准库的一部分
- 在
.pth
个文件之一中指定 - 位于
site-packages
目录 中 - 手动添加到
sys.path
- In current directory, from where you run
python
- Specified via
PYTHONPATH
environment variable - Part of standard library
- Specified in one of
.pth
files - Located in
site-packages
dir - Added to
sys.path
by hand
当您运行setup.py
脚本时,它将踢distutils正确地将软件包的发行版复制到site-packages
,从而将其添加到您的库中.
And when you run setup.py
script, it kicks distutils to properly copy package's distribution to site-packages
, thus adding it to your libs.
有关更多信息,请参见 setup.py用法和导入系统如何工作
For more information, see setup.py usage and how import system works
这篇关于在Windows python中安装Openalpr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!