pip/pipx installation and adding path

820 views Asked by At

I run Debian stable on my box and I want to install the binance connector library

https://github.com/binance/binance-connector-python

to query binance.

I use pipx and everything seems to be OK (see below)

$ sudo pipx install binance-connector --include-deps
⚠️  Note: normalizer was already on your PATH at /usr/bin/normalizer
  installed package binance-connector 3.5.1, installed using Python 3.11.2
  These apps are now globally available
    - normalizer
    - wsdump
⚠️  Note: '/root/.local/bin' is not on your PATH environment variable. These
    apps will not be globally accessible until your PATH is updated. Run `pipx
    ensurepath` to automatically add it, or manually modify your PATH in your
    shell's config file (i.e. ~/.bashrc).
done! ✨  ✨
$ pipx ensurepath
/home/lorenzo/.local/bin is already in PATH.

⚠️  All pipx binary directories have been added to PATH. If you are sure you
want to proceed, try again with the '--force' flag.
$ sudo pipx ensurepath
[sudo] password for lorenzo: 
/root/.local/bin has been been added to PATH, but you need to open a new
    terminal or re-login for this PATH change to take effect.

You will need to open a new terminal or re-login for the PATH changes to take
effect.

Otherwise pipx is ready to go! ✨  ✨

At this point I open a new shell and I type

$ python3.11
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from binance.spot import Spot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'binance'

Does anybody undestand what is going wrong and why the binance library is not found? Many thanks!

1

There are 1 answers

1
Kinuax On

The binance-connector library is not found because it is installed in an isolated virtual environment. pipx's main purpose is to expose Python apps and does not support to import libraries. I would suggest creating a virtual environment (via venv, pipenv, poetry) and installing binance-connector in order to be importable.