安装pysqlcipher3时出现问题 [英] Issue in installing pysqlcipher3

查看:801
本文介绍了安装pysqlcipher3时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,即使pip install pysqlcipher3工作返回了Successfully installed pysqlcipher3,也没有.

So even though pip install pysqlcipher3 worked returned Successfully installed pysqlcipher3, it did not.

根据我的研究,似乎Windows用户尝试安装Sqlcipher时这是一个常见问题.

From my research, it seems that its a common issue for Windows user trying to install Sqlcipher.

尝试#1

首先,我尝试从github下载pysqlcipher3并通过cmd手动构建和安装(使用python setup.py buildpython seetup.py install).

First, I try to download the pysqlcipher3 from github and build and install it manually via cmd (using python setup.py build and python seetup.py install).

执行python3 setup.py build后,出现了一些错误(缺少一些要求,环境变量中没有OPENSSL_CONF ...等),但我修复了大多数错误.

Upon executing python3 setup.py build I got some error (missing few requirements, not having OPENSSL_CONF in environment variable...etc.) but I fix most of them.

但是,我最终因以下错误而陷入困境:

However, I end up stuck with this error:

fatal error C1083: Cannot open include file: 'sqlcipher/sqlite3.h': No such file or directory.

尝试#2

我读到某个地方(我认为),必须先安装 SQLCipher ,然后再安装 PySqlCipher3 .

I read somewhere (I think) that I have to install the SQLCipher before installing the PySqlCipher3.

经检查,我发现我必须付费才能获得预构建的可执行文件,也可以自己构建.

Upon checking, I found out that I have to either pay to get a prebuild executable or build it myself.

所以我尝试按照在安装所有要求之后,并按照步骤进行操作,我遇到了另一个难题.在最后一步(第6步)中,执行nmake /f Makefile.msc时出现此错误:

After installing all requirements, and following the steps I reach another dead end. In the before-last step (step number 6), when executing nmake /f Makefile.msc I got this error:

fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory

我的问题是:

  1. 我读到我需要libsqlcipher,这可能是问题所在.我在哪里可以找到它(首选链接到可执行文件).
  2. 我如何初次尝试解决问题?
  3. 如何在第二次尝试中解决该问题?
  1. I read that I need libsqlcipher which might be the issue. Where can I find it (link to executable preferred).
  2. How can I solve the issue in my first attempt?
  3. How can I solve the issue in my second attempt?

我的目标:是要安装并运行pysqlcipher3.

My goal: Is to have pysqlcipher3 installed and working.

编辑1-解决了尝试#2只是为了解决另一个问题

所以看来我在Visual Studio中缺少某些C ++功能和工具.因此,通过Visual Studio Community安装程序,我下载并安装了基本的C ++东西,它修复了该错误.

So it seems that I was missing some C++ features and tool in Visual Studio. So via Visual Studio Community installer, I download and install basic C++ stuff and it fixed the error.

我遇到另一个错误,可以通过将OpenSSL-Win64\include文件夹复制到C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include来解决.

I got another error which I fix by copying OpenSSL-Win64\include folder to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include.

但是,现在我陷入了这个错误:

However, now I am stuck with this error:

sqlite3.c(77701): warning C4389: '!=': signed/unsigned mismatch
    lib.exe /NOLOGO /MACHINE:x64 /OUT:libsqlite3.lib sqlite3.lo 
    echo EXPORTS > sqlcipher.def
    dumpbin /all libsqlite3.lib  | tclsh .\tool\replace.tcl include "^\s+1 _?(sqlite3(?:session|changeset|changegroup|rebaser)?_[^@]*)(?:@\d+)?$" \1  | sort >> sqlcipher.def
    link.exe /DEBUG   /NOLOGO /MACHINE:x64  /DLL /DEF:sqlcipher.def /OUT:sqlcipher.dll sqlite3.lo sqlite3res.lo  
   Creating library sqlcipher.lib and object sqlcipher.exp
sqlite3.lo : error LNK2019: unresolved external symbol RAND_bytes referenced in function sqlcipher_openssl_random
sqlite3.lo : error LNK2019: unresolved external symbol RAND_add referenced in function sqlcipher_openssl_add_random
sqlite3.lo : error LNK2019: unresolved external symbol OBJ_nid2sn referenced in function sqlcipher_openssl_get_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_MD_size referenced in function sqlcipher_openssl_get_hmac_sz
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CIPHER_nid referenced in function sqlcipher_openssl_get_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CIPHER_block_size referenced in function sqlcipher_openssl_get_block_sz
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CIPHER_key_length referenced in function sqlcipher_openssl_get_key_sz
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CIPHER_iv_length referenced in function sqlcipher_openssl_get_iv_sz
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CipherInit_ex referenced in function sqlcipher_openssl_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CipherUpdate referenced in function sqlcipher_openssl_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CipherFinal_ex referenced in function sqlcipher_openssl_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CIPHER_CTX_new referenced in function sqlcipher_openssl_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CIPHER_CTX_free referenced in function sqlcipher_openssl_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_CIPHER_CTX_set_padding referenced in function sqlcipher_openssl_cipher
sqlite3.lo : error LNK2019: unresolved external symbol EVP_sha1 referenced in function sqlcipher_openssl_get_hmac_sz
sqlite3.lo : error LNK2019: unresolved external symbol EVP_sha256 referenced in function sqlcipher_openssl_get_hmac_sz
sqlite3.lo : error LNK2019: unresolved external symbol EVP_sha512 referenced in function sqlcipher_openssl_get_hmac_sz
sqlite3.lo : error LNK2019: unresolved external symbol EVP_get_cipherbyname referenced in function sqlcipher_openssl_activate
sqlite3.lo : error LNK2019: unresolved external symbol PKCS5_PBKDF2_HMAC referenced in function sqlcipher_openssl_kdf
sqlite3.lo : error LNK2019: unresolved external symbol HMAC_CTX_new referenced in function sqlcipher_openssl_hmac
sqlite3.lo : error LNK2019: unresolved external symbol HMAC_CTX_free referenced in function sqlcipher_openssl_hmac
sqlite3.lo : error LNK2019: unresolved external symbol HMAC_Init_ex referenced in function sqlcipher_openssl_hmac
sqlite3.lo : error LNK2019: unresolved external symbol HMAC_Update referenced in function sqlcipher_openssl_hmac
sqlite3.lo : error LNK2019: unresolved external symbol HMAC_Final referenced in function sqlcipher_openssl_hmac
sqlcipher.dll : fatal error LNK1120: 24 unresolved externals

推荐答案

我也遇到了几乎所有的问题,因此我在下面创建了适用于我的指南

I also had almost all of your problems and so I created this guide below which worked for me

我的构建:Windows 10 x64 v1909

My build: windows 10 x64 v1909

  1. 安装python(如果尚未安装).我有v3.7 64位
  2. 安装 Win64OpenSSL-1_0_2u .确保自我首次下载其他版本以来,您确实获得了该版本,而其他版本则无效.
  3. 为用户和系统SET OPENSSL_CONF=C:\OpenSSL-Win64\bin\openssl.cfg添加环境变量(根据您的情况更改路径)
  4. 安装 sqlcipher 并提取到目录
  5. 打开Visual Studio x64本机工具,然后导航到上面提取的sqlcipher
  6. 目录
  7. 运行命令nmake /f Makefile.msc.最终编译将报告错误,但这没关系,我们在这里不需要真正的编译,只需要sqlite3.c
  8. 获取 pysqlcipher3-1.0.3 ,提取到目录并导航到它
  9. 在其中创建名为amalgamation的文件夹,并在amalgamation文件夹中创建另一个名为sqlcipher的文件夹
  10. 将在Visual Studio步骤(在sqlcipher-master文件夹中)创建的sqlite3.hsqlite3.c复制到amalgamation文件夹和sqlcipher文件夹中
  11. 打开管理命令提示符,然后导航到上面提取的pysqlcipher3-1.0.3
  12. 目录
  13. 运行以下命令python setup.py build_amalgamation
  14. 如OP所述,这将导致链接错误.现在安装 Win32OpenSSL-1_0_2u .先前您安装了x64,现在安装了x32.多次失败后,我学会了这种技巧-:)
  15. 调整环境变量以使SSL指向x32的安装位置,而不是像第3点中那样指向x64
  16. 关闭并重新打开admin CMD,然后重新键入命令python setup.py build_amalgamation.这次应该可以正常运行了,没有任何错误.
  17. 现在运行以下命令python setup.py install
  18. 如果一切顺利,则此命令应在cmd >> python >> from pysqlcipher3 import dbapi2
  19. 中运行
  1. Install python (if not already installed). I had v3.7 64 bit
  2. Install Win64OpenSSL-1_0_2u. Make sure you get exactly this version since I first downloaded some other versions and they didn't work.
  3. Add environment variable for both user and system SET OPENSSL_CONF=C:\OpenSSL-Win64\bin\openssl.cfg (change path as per yours)
  4. Install ActiveTcl-8.6.9.8609.2-MSWin32-x64. This was latest at this time and worked
  5. Install visual studio (if not already installed). I had VS2019 v16.5.5
  6. Get sqlcipher and extract to directory
  7. Open visual studio x64 native tools and navigate to above extracted directory of sqlcipher
  8. Run command nmake /f Makefile.msc. The final compilation will report an error, but it does not matter, we do not need a real compilation here, only need sqlite3.c
  9. Get pysqlcipher3-1.0.3, extract to directory and navigate to it
  10. Create folder named amalgamation in it and create another folder named sqlcipher in amalgamation folder
  11. Copy sqlite3.h and sqlite3.c created in Visual Studio step (in sqlcipher-master folder) to amalgamation folder and sqlcipher folder both
  12. Open administrative command prompt and navigate to above extracted directory of pysqlcipher3-1.0.3
  13. Run following command python setup.py build_amalgamation
  14. This will give linkage errors as OP has stated. Now install Win32OpenSSL-1_0_2u. Earlier you installed x64 and now installing x32. I learnt this hack after multiple failures -:)
  15. Adjust the environment variables for SSL to point to x32 installed location instead of x64 as done in point-3
  16. Close and reopen admin CMD and retype the command python setup.py build_amalgamation. This time it should work well without any errors.
  17. Now run following command python setup.py install
  18. If all goes well then this command should work in cmd>>python>>from pysqlcipher3 import dbapi2

一些对我有用的链接 1 4 5

Some Useful Links for me 1, 2, 3, 4, 5

如果由于将来链接断开而无法获得确切的版本,则可以发表评论,如果那时我有,我将上传到云驱动器.

If you don't get exact versions as mine due to links broken in future, you can comment and if I have them at that time, I'll upload to a cloud drive.

这篇关于安装pysqlcipher3时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆