ssh2-python icon indicating copy to clipboard operation
ssh2-python copied to clipboard

ModuleNotFoundError: import ssh2.session

Open acarlstein opened this issue 8 months ago • 2 comments

I tried everything to make this work:

brew install cmake
brew install libssh2
pip install --upgrade pip setuptools wheel
pip install ssh2-python
brew info libssh2

Everything seems to work but when I try to run my python code it fails on the import!!!

Image

acarlstein avatar Apr 19 '25 18:04 acarlstein

Thanks for the interest.

pip show ssh2-python will confirm it is installed. python -c 'import ssh2.session' to confirm it is installed correctly.

Use command line and show steps to reproduce with error message(s) if you think there is an issue with the library.

pkittenis avatar Apr 24 '25 11:04 pkittenis

@pkittenis Thank you for answering the issue I created.

I run both commands. The second command fails.

% pip show ssh2-python                                                                     main
Name: ssh2-python
Version: 1.1.2.post1
Summary: Bindings for libssh2 C library
Home-page: https://github.com/ParallelSSH/ssh2-python
Author: Panos Kittenis
Author-email: [email protected]
License: LGPLv2
Location: /usr/local/lib/python3.11/site-packages
Requires: 
Required-by: 
 % python3 -c 'import ssh2.session'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import ssh2.session
ModuleNotFoundError: No module named 'ssh2'

acarlstein avatar Apr 27 '25 18:04 acarlstein

Your pip seems to not match your python3 version.

Use python3 -m pip install ssh2-python if you are not sure which pip is for which python.

pkittenis avatar Aug 25 '25 18:08 pkittenis