mattboyer/sqbrite

Installation error

Closed this issue · 3 comments

im trying to install sqbrite on a windows 10 and this is the error I get. It doesnt work on a Mac M1 either.

C:\Users\LF>pip3 install --user sqbrite
Requirement already satisfied: sqbrite in c:\users\lf\appdata\roaming\python\python310\site-packages (0.17)    
Requirement already satisfied: pyxdg in c:\users\lf\appdata\roaming\python\python310\site-packages (from sqbrite)(0.28)
Requirement already satisfied: pyyaml in c:\users\lf\appdata\roaming\python\python310\site-packages (from sqbrite) (6.0)                                                                           C:\Users\LF>sqbrite --help
'sqbrite' is not recognized as an internal or external command,                                                 
operable program or batch file. 

Hello.

It looks like sqbrite is indeed installed in your user's "local" directory structure, but the Windows command interpreter (either the old cmd.exe or PowerShell) doesn't know that it should look for executables there.

As a first step, would you please run:

pip3 show -v sqbrite

...and look for the line that starts with Location in the output, as well as the one that has bin/sqbrite. If you're using PowerShell, I think pip3 list -v sqbrite | Select-String 'Location|bin' should do it for you, but I'm not able to test it as I don't have access to a Windows system.

Regardless, you should see a location that's probably c:\users\lf\appdata\roaming\python\python310\site-packages and a relative path for the executable that's likely something similar to ../../../bin/sqbrite. The path where that sqbrite lives is what you'll want to add to your command interpreter's PATH environment variable.

I would expect this issue to affect not just sqbrite, but every other user-installed Python package.

Hi again! This is my output. I don't have the Location bin:

C:\Users\LF>pip3 show -v sqbrite
Name: sqbrite
Version: 0.17
Summary: SQBrite is a data recovery tool for SQLite databases
Home-page: https://github.com/mattboyer/sqbrite
Author: Matt Boyer
Author-email: mboyer@sdf.org
License: UNKNOWN
Location: c:\users\lf\appdata\roaming\python\python310\site-packages
Requires: pyxdg, pyyaml
Required-by:
Metadata-Version: 2.1
Installer: pip
Classifiers:
Development Status :: 2 - Pre-Alpha
Intended Audience :: Science/Research
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Database
Topic :: System :: Recovery Tools
Entry-points:
[console_scripts]
sqbrite = sqbrite.sqlite_recover:main
Project-URLs:

I went ahead and installed Python 3.10 on a Windows 10 VM to try and reproduce this.

The good news is that I'm now fairly confident this isn't an issue with the SQBrite packaging, but your environment being incorrectly configured.

After installing the Python 3.10 package for Windows, I made no attempt to manipulate the Powershell interpreter's PATH environment variable to let it know where the Python stuff could be found.

Therefore, at that juncture, I had the Python interpreter installed at C:\Users\mboyer\AppData\Local\Programs\Python\Python310\python.exe, and I had to navigate to that directory to execute it:

PS C:\Users\mboyer\AppData\Local\Programs\Python\Python310> .\python.exe -m pip

Usage:
  C:\Users\mboyer\AppData\Local\Programs\Python\Python310\python.exe -m pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  inspect                     Inspect the python environment.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  cache                       Inspect and manage pip's wheel cache.
  index                       Inspect information available from package indexes.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --debug                     Let unhandled exceptions propagate outside the main subroutine, instead of logging them to stderr.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  --require-virtualenv        Allow pip to only run in a virtual environment; exit with an error otherwise.
  --python <python>           Run pip with the specified Python interpreter.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --no-input                  Disable prompting for input.
  --proxy <proxy>             Specify a proxy in the form scheme://[user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to PEM-encoded CA certificate bundle. If provided, overrides the default. See 'SSL Certificate Verification' in pip documentation for more
                              information.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
  --no-color                  Suppress colored output.
  --no-python-version-warning
                              Silence deprecation warnings for upcoming unsupported Pythons.
  --use-feature <feature>     Enable new functionality, that may be backward incompatible.
  --use-deprecated <feature>  Enable deprecated functionality, that will be removed in the future.

Likewise, I couldn't run pip directly, but had to use the somewhat clunky python -m pip. However, a critical clue was given by Pip itself when I upgraded it:

PS C:\Users\mboyer\AppData\Local\Programs\Python\Python310> .\python.exe -m pip install --upgrade --user pip
Requirement already satisfied: pip in c:\users\mboyer\appdata\local\programs\python\python310\lib\site-packages (22.3.1)
Collecting pip
  Downloading pip-23.0-py3-none-any.whl (2.1 MB)
     ---------------------------------------- 2.1/2.1 MB 7.7 MB/s eta 0:00:00
Installing collected packages: pip
  WARNING: The scripts pip.exe, pip3.10.exe and pip3.exe are installed in 'C:\Users\mboyer\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-23.0

[notice] A new release of pip available: 22.3.1 -> 23.0
[notice] To update, run: python.exe -m pip install --upgrade pip

I did exactly what pip suggested, and from that point on I was able to access pip from anywhere, and indeed sqbrite after I installed it:

PS C:\Users\mboyer\AppData\Local\Programs\Python\Python310> $Env:Path+='C:\Users\mboyer\AppData\Roaming\Python\Python310\Scripts'

PS C:\Users\mboyer\AppData\Local\Programs\Python> pip install --user sqbrite
Collecting sqbrite
  Downloading sqbrite-0.17-py3-none-any.whl (30 kB)
Collecting pyxdg
  Downloading pyxdg-0.28-py2.py3-none-any.whl (49 kB)
     ---------------------------------------- 49.5/49.5 kB 2.5 MB/s eta 0:00:00
Collecting pyyaml
  Downloading PyYAML-6.0-cp310-cp310-win_amd64.whl (151 kB)
     ---------------------------------------- 151.7/151.7 kB 9.4 MB/s eta 0:00:00
Installing collected packages: pyxdg, pyyaml, sqbrite
Successfully installed pyxdg-0.28 pyyaml-6.0 sqbrite-0.17

PS C:\Users\mboyer\AppData\Local\Programs\Python> pip show -v sqbrite
Name: sqbrite
Version: 0.17
Summary: SQBrite is a data recovery tool for SQLite databases
Home-page: https://github.com/mattboyer/sqbrite
Author: Matt Boyer
Author-email: mboyer@sdf.org
License: UNKNOWN
Location: c:\users\mboyer\appdata\roaming\python\python310\site-packages
Requires: pyxdg, pyyaml
Required-by:
Metadata-Version: 2.1
Installer: pip
Classifiers:
  Development Status :: 2 - Pre-Alpha
  Intended Audience :: Science/Research
  License :: OSI Approved :: MIT License
  Programming Language :: Python :: 3.5
  Programming Language :: Python :: 3.6
  Programming Language :: Python :: 3.7
  Programming Language :: Python :: 3.8
  Programming Language :: Python :: 3.9
  Programming Language :: Python :: 3.10
  Topic :: Database
  Topic :: System :: Recovery Tools
Entry-points:
  [console_scripts]
  sqbrite = sqbrite.sqlite_recover:main
Project-URLs:

PS C:\Users\mboyer\AppData\Local\Programs\Python> sqbrite.exe
usage: sqbrite [-h] [-v] {csv,list,grep,undelete} ...

SQBrite is a data recovery tool for SQLite databases

options:
  -h, --help            show this help message and exit
  -v, --verbose         Give *A LOT* more output.

Subcommands:
  sqbrite implements the following subcommands:

  {csv,list,grep,undelete}
    csv                 Dumps visible and recovered records to CSV files
    list                Displays supported DB types
    grep                Matches a string in one or more pages of the database
    undelete            Inserts recovered records into a copy of the database

The actual location of the sqbrite.exe created during installation was C:\Users\mboyer\AppData\Roaming\Python\Python310\Scripts\sqbrite.exe, but that shouldn't really be a user-visible detail.

What matters is that, in order for a Windows Python install to be functional, your PATH environment variable has to include the Scripts directory. In your case, that would be achieved by running:

$Env:Path+='C:\Users\lf\AppData\Roaming\Python\Python310\Scripts'

Closing this issue as it's not a bug in SQBrite.