So I'm trying to use Paramiko on Ubuntu with Python 2.7, but import paramiko causes this error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named paramiko
The other questions on this site don't help me since I'm new to Ubuntu.
Here are some important commands that I ran to check stuff:
sudo pip install paramiko
pip install paramiko
sudo apt-get install python-paramiko
Paramiko did "install". These are the only commands I used to "install" paramiko. I'm new to Ubuntu, so if I need to run more commands, lay them on me.
which python
/usr/local/bin/python
python -c "from pprint import pprint; import sys; pprint(sys.path);"
['',
 '/usr/local/lib/python27.zip',
 '/usr/local/lib/python2.7',
 '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk',
 '/usr/local/lib/python2.7/lib-old',
 '/usr/local/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/site-packages']
In the python interpreter, I ran help("modules") and Paramiko is not in the list.
two paramiko folders are located in usr/local/lib/python2.7/dist-packages.
Short version: You're mixing Ubuntu's packaged version of Python (/usr/bin/python) and a locally built and installed version (/usr/local/bin/python).
Long version:
apt-get install python-paramiko to install Ubuntu's official Paramiko package to /usr/lib/python2.7/dist-packages.pip, which installs to /usr/local/lib/python2.7/dist-packages. (See here.)/usr/local/lib/python2.7 instead of /usr/lib/python2.7, and because it doesn't have Debian/Ubuntu customizations, it doesn't check use dist-packages.Solution: You should be able to add /usr/local/lib/python2.7/dist-packages to your /usr/local/bin/python's sys.path, but since you're using Ubuntu, it's easiest to let Ubuntu do the work for you:
apt-get instead of pip).I'd go so far as to uninstall the local version of Python and delete /usr/local/lib/python2.7, to ensure that no further mismatches occur.  If you don't want to be that drastic, then you can edit your $PATH to put /usr/bin before /usr/local/bin to run the system version of Python by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With