1

When I try to import paramiko, when I try to run rforward.py from the paramiko demo files, it shows error :

./rforward.py
Traceback (most recent call last):
  File "./rforward.py", line 36, in <module>
    import paramiko
ImportError: No module named paramiko

And when I try to install paramiko via pip,

pip install paramiko

It shows :

Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (2.6.0)

My python version is 2.7.18. I had installed paramiko for a different python3 program using pip3 install paramiko Will completely removing it and re-installing it with pip instead of pip3 help? Will this loose the module from python3
EDIT :

python --version
Python 2.7.18
find /usr/lib/python3/dist-packages -iname "*paramiko*"

/usr/lib/python3/dist-packages/paramiko
/usr/lib/python3/dist-packages/paramiko-2.6.0.egg-info

Any suggestions please? Thanks in advance

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40
  • 1
    Is this an issue between installing as user, but running your `rforward.py` as administrator? If that's the case, run `pip install paramiko` as administrator as well - otherwise the library ends up in your user folder and "not accessible" by administrator. – Torxed Jun 08 '20 at 08:41
  • What is `which python` resulting in? – albert Jun 08 '20 at 08:44
  • @albert /usr/bin/python – Roshin Raphel Jun 08 '20 at 08:56
  • @Torxed is installed as admin – Roshin Raphel Jun 08 '20 at 08:56
  • 1
    `python --version` and `find /usr/lib/python3/dist-packages -iname "*paramiko*"`. Add the results in your question not in the comment section. – Torxed Jun 08 '20 at 08:58
  • Ah wait, you have to do `pip2 install paramiko`, if you're running Python3 as the standard python. Are you running Arch LInux for instance, the default pip and python will be 3, but if you're running python2 enforced you'll have to force-use the Python2 version of PIP as well. – Torxed Jun 08 '20 at 09:00
  • It is not working, ```bash: pip2: command not found``` – Roshin Raphel Jun 08 '20 at 09:04
  • Lets start from the beginning, what operating system are you running (specifics are important) – Torxed Jun 08 '20 at 10:30
  • @Torxed Ubuntu 18.04 LTS – Roshin Raphel Jun 08 '20 at 10:31
  • Your default version of Python (and pip) should there for be `python2` and `pip` (implying pip2). What does `pip --version` say? – Torxed Jun 08 '20 at 10:33
  • ```pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)``` – Roshin Raphel Jun 08 '20 at 10:34
  • 1
    If you are only just learning the basics, you should probably ignore Python 2, and spend your time on the currently recommended and supported version of the language, which is Python 3. – tripleee Jul 23 '20 at 11:37
  • @tripleee Na, I had a piece of code which was in python2. It was a pain in the ass to convert it into python3. So I thought to run it in the same. Any way, thanks for the suggestion. – Roshin Raphel Jul 23 '20 at 11:40
  • 1
    This thread helped my particular case, hope it does help you too https://stackoverflow.com/questions/65869296/installing-pip-is-not-working-in-python-3-6 – Arnas Valteris Sep 10 '21 at 07:22

1 Answers1

0

Issue was with pip. The pip and pip3 I had installed in the same path, /usr/lib/python3/dist-packages. I installed a pip specifically for python 2.7. Using this. Now pip installs for python and pip3 for python3.

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40