ModuleNotFoundError for installed module

Getting ModuleNotFoundError for recently installed module. There are a lot of similar topics in google, however tips from there (use python3 -m pip instead of pip or use virtual env) didn’t help me. I also tried both with root and non-root user. Error is always the same. My OS is Debian 12.8 (fresh installation, only single python binary) and python version is 3.11. Any help is appreciated.

Please show the commands run, pip and python, and the error you see.

What module did you install?

What command did you use to install it, exactly?

What is the import statement causing this error, exactly?

What is the output of where python3 and where pip3 in your Terminal?

1 Like
term@taz:~$ python3 -m pip install --break-system-packages okx.Trade
Requirement already satisfied: okx.Trade in /usr/local/lib/python3.11/dist-packages (1.0.2)
Requirement already satisfied: candlelite in /usr/local/lib/python3.11/dist-packages (from okx.Trade) (1.0.17)
Requirement already satisfied: paux>=1.0.5 in /usr/local/lib/python3.11/dist-packages (from okx.Trade) (1.0.14)
Requirement already satisfied: okx>=1.0.7 in /usr/local/lib/python3.11/dist-packages (from okx.Trade) (2.1.1)
Requirement already satisfied: okx-candle>=1.0.5 in /usr/local/lib/python3.11/dist-packages (from okx.Trade) (2.0.1)
Requirement already satisfied: urllib3 in /usr/lib/python3/dist-packages (from okx>=1.0.7->okx.Trade) (1.26.12)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from okx>=1.0.7->okx.Trade) (2.28.1)
Requirement already satisfied: pandas in /usr/local/lib/python3.11/dist-packages (from okx>=1.0.7->okx.Trade) (2.2.3)
Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from okx>=1.0.7->okx.Trade) (2.2.1)
Requirement already satisfied: pendulum in /usr/local/lib/python3.11/dist-packages (from okx-candle>=1.0.5->okx.Trade) (3.0.0)
Requirement already satisfied: redis in /usr/local/lib/python3.11/dist-packages (from paux>=1.0.5->okx.Trade) (5.2.1)
Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.11/dist-packages (from pandas->okx>=1.0.7->okx.Trade) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/dist-packages (from pandas->okx>=1.0.7->okx.Trade) (2024.2)
Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/dist-packages (from pandas->okx>=1.0.7->okx.Trade) (2024.2)
Requirement already satisfied: time-machine>=2.6.0 in /usr/local/lib/python3.11/dist-packages (from pendulum->okx-candle>=1.0.5->okx.Trade) (2.16.0)
Requirement already satisfied: async-timeout>=4.0.3 in /usr/local/lib/python3.11/dist-packages (from redis->paux>=1.0.5->okx.Trade) (5.0.1)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->okx>=1.0.7->okx.Trade) (1.16.0)
term@taz:~$ python3 -c 'import okx.Trade'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'okx.Trade'

Module name okx.Trade
Tried both python3 -m pip install --break-system-packages okx.Trade and pip install --break-system-packages okx.Trade

python3 -c 'import okx.Trade'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'okx.Trade'

whereis python3
python3: /usr/bin/python3 /usr/lib/python3 /etc/python3 /usr/share/python3 /usr/share/man/man1/python3.1.gz
whereis pip3
pip3: /usr/bin/pip3 /usr/share/man/man1/pip3.1.gz

I expect that the spelling on the import is not the same as for the pip command. Have a look at the docs for the module to find out how it should be imported. You could also look in /usr/local/lib/python3.11/dist-packages to see how the modules spells its nsne.

I’m following API documentation https://www.okx.com/docs-v5/en/?python#order-book-trading-trade-post-place-order and it says to import that way.

term@taz:~$ ls -l  /usr/local/lib/python3.11/dist-packages |grep okx
drwxr-xr-x  5 term root  4096 Jan  3 14:47 okx
drwxr-xr-x  2 term root  4096 Jan  3 14:47 okx-2.1.1.dist-info
drwxr-xr-x  7 term root  4096 Jan  3 14:48 okx_candle
drwxr-xr-x  2 term root  4096 Jan  3 14:48 okx_candle-2.0.1.dist-info
drwxr-xr-x  7 term root  4096 Jan  3 14:48 okx_trade
drwxr-xr-x  2 term root  4096 Jan  3 14:48 okx_trade-1.0.2.dist-info

The docs do not match the installed files…

Try import okx_trade.

I suspect you haven’t installed the package you intended to install. The documentation you linked to is apparently for the package listed on pypi as python-okx, found here. I think you installed the package listed on PyPI as okx-trade, found here.

Try uninstalling your okx-trade and instead install python-okx.

1 Like