Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from pysqlcipher3 import dbapi2 as sqlite (no module named 'pysqlcipher3' #21

Open
tammy20-20 opened this issue Oct 24, 2020 · 3 comments

Comments

@tammy20-20
Copy link

in virtual environment, i type pip install pysqlcipher3. Seems building ok but having failed msg like below:
(venv) c:\Users\user\Desktop\ty3\venv\Scripts>pip install pysqlcipher3
Collecting pysqlcipher3
Using cached pysqlcipher3-1.0.3.tar.gz (100 kB)
Building wheels for collected packages: pysqlcipher3
Building wheel for pysqlcipher3 (setup.py) ... done
WARNING: Legacy build of wheel for 'pysqlcipher3' created no files.
Command arguments: 'C:\Users\user\Desktop\ty3\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\user\AppData\Local\Temp\pip-install-iqf9_056\pysqlcipher3\setup.py'"'"'; file='"'"'C:\Users\user\AppData\Local\Temp\pip-install-iqf9_056\pysqlcipher3\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\user\AppData\Local\Temp\pip-wheel-4kesfxr6'
Command output: [use --verbose to show]
Running setup.py clean for pysqlcipher3
Failed to build pysqlcipher3
Installing collected packages: pysqlcipher3
Running setup.py install for pysqlcipher3 ... done
Successfully installed pysqlcipher3
WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available.
You should consider upgrading via the 'C:\Users\user\Desktop\ty3\venv\Scripts\python.exe -m pip install --upgrade pip' command.

Then i go to python and and type command: from pysqlcipher3 import dbapi2 as sqlite

Failed with below msg:

from pysqlcipher3 import dbapi2 as sqlite
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pysqlcipher3'
import pysqlcipher3
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pysqlcipher3'

I am using Win 10. I have sourced this problem but still don't know how to fix it. I am new to Python. Need help please.

@98yejin
Copy link

98yejin commented Dec 9, 2020

Did you solve the problem?
my solution is little bit complicated. If it's okay to you, refer to it.

First, using pip doesn't works for me. so I use other way

https://github.com/sqlitebrowser/sqlitebrowser/wiki/Win64-setup-%E2%80%94-Compiling-SQLCipher

in the above page, you can install sqlcipher.
and don't forget to set path(PATH and OPENSSL_CONF)

Second, now we can install pysqlcipher3

$ git clone https://github.com/rigglemania/pysqlcipher3

Follow the instructions on the README.md page.
but if you using vs 2019 community edition, the VC include directory path is little bit complicated
my path is

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include

and move sqlite3.lib sqlcipher.lib files to the

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\lib\x64

and after this all.. below commands will work.

$ cd pysqlcipher3
$ python setup.py build
$ python setup.py install

and if this not works you have few things to do

go to below directory

C:\git_repos\pysqlcipher3\src\python3

and you can see several header files
open it and change 'sqlcipher/sqlcipher.h' to 'sqlcipher.h'
do it to every header files which includes 'sqlcipher/sqlcipher.h'

and because .. your using virtual machine
even if you succeed to install pysqlcipher3.. you can see the error that you don't have a dll files

then you can go to below folder

C:\Users\your computer name\.conda\envs\your virtual machine name
(path can be different)

and move sqlcipher.dll file to above folder

and after this all.. you can use pysqlcipher3 library

@ryan-williams
Copy link

I saw this error (ModuleNotFoundError: No module named 'pysqlcipher3' when trying to import pysqlcipher3, after pip install pysqlcipher3).

This warning while pip installing is important:

WARNING: Legacy build of wheel for 'pysqlcipher3' created no files.

You need libsqlcipher to be installed on your system for pip install pysqlcipher3 to actually install the library.

This fixed it on ubuntu:

sudo apt-get install libsqlcipher-dev

(must be run before pip install pysqlcipher3)

On my macbook, I think you want:

brew install sqlcipher

@falkoschindler
Copy link

With MacOS Monterey on an M1 with Python 3.10 I just had to do the following procedure to get pysqlcipher3 working again:

  1. Get pysqlcipher3:

    git clone https://github.com/rigglemania/pysqlcipher3.git
    
  2. Get sqlite3.c and sqlite3.h and move them to pysqlcipher3:

    git clone https://github.com/sqlcipher/sqlcipher
    cd sqlcipher/
    ./configure
    make sqlite3.c
    cp sqlite3.[ch] pysqlcipher3/src/python3/
    
  3. Install openssl and sqlcipher and set compiler flags accordingly:

    brew install openssl
    brew info openssl
    export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
    
    brew install sqlcipher
    brew info sqlcipher
    export LDFLAGS="-L/opt/homebrew/Cellar/sqlcipher/4.5.1/lib"
    
  4. Fix code for Python 3.10:

    Change _PyUnicode_AsStringAndSize to PyUnicode_AsUTF8AndSize in pysqlcipher3/src/python3

  5. Build and install pysqlcipher3:

    python setup.py build
    python setup.py install
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants