在安装python的Postal(Address Parser)软件包时出现问题

时间:2020-01-14 09:02:49

标签: python-3.x msys2 visual-studio-2017-build-tools

我正在尝试使用

安装邮政软件包
pip install postal

我正在执行链接中提到的步骤 https://github.com/openvenues/libpostal#installation-windows

我已经安装了Visual Studio 2019 C ++生成工具MSYS2并执行了该步骤

git clone https://github.com/openvenues/libpostal
cd libpostal
cp -rf windows/* ./
./bootstrap.sh
./configure --datadir=[...some dir with a few GB of space...]
make -j4
make install

仍然无法使用pip install postal安装邮包

在安装邮政软件包时获取以下日志。

(base) C:\Users\Praveen>pip install postal
Collecting postal
  Using cached https://files.pythonhosted.org/packages/56/f7/69ca5d374077e23aa9a51ecd4031222ca9dfb7d19c95d7691f024e2e27ef/postal-1.1.8.tar.gz
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from postal) (1.12.0)
Building wheels for collected packages: postal
  Building wheel for postal (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\ProgramData\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Praveen\\AppData\\Local\\Temp\\pip-install-9sens8xe\\postal\\setup.py'"'"'; __file__='"'"'C:\\Users\\Praveen\\AppData\\Local\\Temp\\pip-install-9sens8xe\\postal\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Praveen\AppData\Local\Temp\pip-wheel-e6vpt_0y' --python-tag cp37
       cwd: C:\Users\Praveen\AppData\Local\Temp\pip-install-9sens8xe\postal\
  Complete output (35 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.7
  creating build\lib.win-amd64-3.7\postal
  copying postal\dedupe.py -> build\lib.win-amd64-3.7\postal
  copying postal\expand.py -> build\lib.win-amd64-3.7\postal
  copying postal\near_dupe.py -> build\lib.win-amd64-3.7\postal
  copying postal\normalize.py -> build\lib.win-amd64-3.7\postal
  copying postal\parser.py -> build\lib.win-amd64-3.7\postal
  copying postal\tokenize.py -> build\lib.win-amd64-3.7\postal
  copying postal\token_types.py -> build\lib.win-amd64-3.7\postal
  copying postal\__init__.py -> build\lib.win-amd64-3.7\postal
  creating build\lib.win-amd64-3.7\postal\tests
  copying postal\tests\test_expand.py -> build\lib.win-amd64-3.7\postal\tests
  copying postal\tests\test_parser.py -> build\lib.win-amd64-3.7\postal\tests
  copying postal\tests\_test_near_dupes.py -> build\lib.win-amd64-3.7\postal\tests
  copying postal\tests\__init__.py -> build\lib.win-amd64-3.7\postal\tests
  creating build\lib.win-amd64-3.7\postal\utils
  copying postal\utils\encoding.py -> build\lib.win-amd64-3.7\postal\utils
  copying postal\utils\enum.py -> build\lib.win-amd64-3.7\postal\utils
  copying postal\utils\omitted.py -> build\lib.win-amd64-3.7\postal\utils
  copying postal\utils\__init__.py -> build\lib.win-amd64-3.7\postal\utils
  copying postal\pyutils.h -> build\lib.win-amd64-3.7\postal
  running build_ext
  building 'postal._expand' extension
  creating build\temp.win-amd64-3.7
  creating build\temp.win-amd64-3.7\Release
  creating build\temp.win-amd64-3.7\Release\postal
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/local/include -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcpostal/pyexpand.c /Fobuild\temp.win-amd64-3.7\Release\postal/pyexpand.obj -std=c99
  cl : Command line warning D9002 : ignoring unknown option '-std=c99'
  pyexpand.c
  postal/pyexpand.c(2): fatal error C1083: Cannot open include file: 'libpostal/libpostal.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.20.27508\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for postal
  Running setup.py clean for postal
Failed to build postal
Installing collected packages: postal
  Running setup.py install for postal ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\ProgramData\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Praveen\\AppData\\Local\\Temp\\pip-install-9sens8xe\\postal\\setup.py'"'"'; __file__='"'"'C:\\Users\\Praveen\\AppData\\Local\\Temp\\pip-install-9sens8xe\\postal\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Praveen\AppData\Local\Temp\pip-record-k92kr5uk\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\Praveen\AppData\Local\Temp\pip-install-9sens8xe\postal\
    Complete output (35 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\postal
    copying postal\dedupe.py -> build\lib.win-amd64-3.7\postal
    copying postal\expand.py -> build\lib.win-amd64-3.7\postal
    copying postal\near_dupe.py -> build\lib.win-amd64-3.7\postal
    copying postal\normalize.py -> build\lib.win-amd64-3.7\postal
    copying postal\parser.py -> build\lib.win-amd64-3.7\postal
    copying postal\tokenize.py -> build\lib.win-amd64-3.7\postal
    copying postal\token_types.py -> build\lib.win-amd64-3.7\postal
    copying postal\__init__.py -> build\lib.win-amd64-3.7\postal
    creating build\lib.win-amd64-3.7\postal\tests
    copying postal\tests\test_expand.py -> build\lib.win-amd64-3.7\postal\tests
    copying postal\tests\test_parser.py -> build\lib.win-amd64-3.7\postal\tests
    copying postal\tests\_test_near_dupes.py -> build\lib.win-amd64-3.7\postal\tests
    copying postal\tests\__init__.py -> build\lib.win-amd64-3.7\postal\tests
    creating build\lib.win-amd64-3.7\postal\utils
    copying postal\utils\encoding.py -> build\lib.win-amd64-3.7\postal\utils
    copying postal\utils\enum.py -> build\lib.win-amd64-3.7\postal\utils
    copying postal\utils\omitted.py -> build\lib.win-amd64-3.7\postal\utils
    copying postal\utils\__init__.py -> build\lib.win-amd64-3.7\postal\utils
    copying postal\pyutils.h -> build\lib.win-amd64-3.7\postal
    running build_ext
    building 'postal._expand' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\postal
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/local/include -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcpostal/pyexpand.c /Fobuild\temp.win-amd64-3.7\Release\postal/pyexpand.obj -std=c99
    cl : Command line warning D9002 : ignoring unknown option '-std=c99'
    pyexpand.c
    postal/pyexpand.c(2): fatal error C1083: Cannot open include file: 'libpostal/libpostal.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.20.27508\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\ProgramData\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Praveen\\AppData\\Local\\Temp\\pip-install-9sens8xe\\postal\\setup.py'"'"'; __file__='"'"'C:\\Users\\Praveen\\AppData\\Local\\Temp\\pip-install-9sens8xe\\postal\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Praveen\AppData\Local\Temp\pip-record-k92kr5uk\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

1 个答案:

答案 0 :(得分:0)

尝试以下解决方案。我正在WSL中运行它。

更改

  1. 在所有命令之前导航到cd〜目录。
  2. 在制作前使用'sudo'。
Error: Cannot find module 'E:\Project\Electron\MoeEx\node_modules\electron\dist\Extensions\test.js'

然后运行 //payee model public class Payee { @Id private String id; private Contact contact; private String notes; private String project; private String member; private Integer staffMember; private Photo photo; private BankAccount userBankAccount; private PayeeBankAccount payeeBankAccountList; public Payee(Contact contact, String notes, String project, String member, Integer staffMember, Photo photo, BankAccount userBankAccount, PayeeBankAccount payeeBankAccountList) { this.contact = contact; this.notes = notes; this.project = project; this.member = member; this.staffMember = staffMember; this.photo = photo; this.userBankAccount = userBankAccount; this.payeeBankAccountList = payeeBankAccountList; } public String getId() {return id;} public void setId(String id) {this.id = id;} public Contact getContact() { return contact; } public void setContact(Contact contact) { this.contact = contact; } public String getNotes() { return notes; } public void setNotes(String notes) { this.notes = notes; } public String getProject() { return project; } public void setProject(String project) { this.project = project; } public String getMember() { return member; } public void setMember(String member) { this.member = member; } public Integer getStaffMember() { return staffMember; } public void setStaffMember(Integer staffMember) { this.staffMember = staffMember; } public Photo getPhoto() {return photo;} public void setPhoto(Photo photo) {this.photo = photo;} public BankAccount getUserBankAccount() { return userBankAccount; } public void setUserBankAccount(BankAccount userBankAccount) { this.userBankAccount = userBankAccount} public PayeeBankAccount getPayeeBankAccountList() { return payeeBankAccountList; } public void setPayeeBankAccountList(PayeeBankAccount payeeBankAccountList){this.payeeBankAccountList= payeeBankAccountList; } } //photo model public class Photo { @Id private String id; private String title; private Binary image; public Photo(String id, String title, Binary image) { this.id = id; this.title = title; this.image = image; } public Photo(String title) { super(); this.title = title; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public Binary getImage() { return image; } public void setImage(Binary image) { this.image = image; } @Override public String toString() { return "Photo \[id=" + id + ", title=" + title + ", image=" + image + "\]"; } } //photo service @Service public class PhotoService { @Autowired private PhotoRepository photoRepo; public Photo getPhoto(String id) { return photoRepo.findById(id).get(); } public String addPhoto(String title, MultipartFile file) throws IOException { Photo photo = new Photo(title); photo.setImage(new Binary(BsonBinarySubType.BINARY, file.getBytes())); photo = photoRepo.insert(photo); return photo.getId(); } } //add payee @PostMapping('/addPayee') public void insert(@RequestBody Payee payee){ this.payeeRepository.save(payee); } //add photo @PostMapping('/photos/add') public String addPhoto(@RequestBody Payee payee , @RequestParam("title") String title, @RequestParam("image") MultipartFile image, Model model) throws IOException { String id = photoService.addPhoto(title,image); return id; }][1]][1] [1]: https://i.stack.imgur.com/lF6KZ.png

from wagtail.images.models import Image from django.core.files.images import ImageFile from io import BytesIO class Command(BaseCommand): help = "Import an image from filepath" def add_arguments(self, parser): parser.add_argument('filepath') def handle(self, *args, **options): # You child will be added to the parent parent = YourParentObject.objects.first() your_object = YourObject(title="Something",...) if exists(options["filepath"]): # Open the file as binary with open(filepath,"rb") as imagefile: # Gets the name of the file filename = filepath.split("/")[-1] image = Image(file=ImageFile(BytesIO(imagefile.read()), name=filename)) image.save() your_object.your_image_field = image # now you can save your model parent.add_child(instance=your_object) ,然后导入并运行邮政库。