ImportError: No module named 'paramiko' - python

I have done through the other questions online here, and I feel that mine is different enough to warrant a new question.
So I have a Centos 6 box, which is running a small website for me, acts as an office git server and I am trying to configure Python3 on it.
So I followed the following these steps to set up python3 on the server. However it seems that I cannot import paramiko into my script.
I downloaded the paramiko rpm however I get this message:
When I try to import paramiko I get:
[root#GIT Python-3.4.2]# rpm -ivh /usr/lib/Python-3.4.2/Modules/python-paramiko-1.7.5-2.1.el6.noarch.rpm
Preparing... ########################################### [100%]
package python-paramiko-1.7.5-2.1.el6.noarch is already installed
When I run python3 directly:
[root#GIT inserv_health_check]# python3
Python 3.4.2 (default, Jan 21 2015, 06:28:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'paramiko'
>>>
I am sure there is a simple solution to this problem perhaps the path is wrong, or I should have put a symbolic link in somewhere. Any help would be appreciated :)
Before anyone asks, which python output:
[root#GIT Python-3.4.2]# which python
/usr/bin/python
[root#GIT Python-3.4.2]# which pytho~n3
/usr/bin/which: no pytho~n3 in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[root#GIT Python-3.4.2]# which python3
/usr/local/bin/python3
Thanks

You need to do pip install paramiko so that python sees that module. If you work on a virtual environment, you need to workon <env_name> first and then pip install the desired module.

type pip3 install paramiko
if you want to install it for python3

Related

No module named 'mysql'

I've created a Python script to store data in MySQL. It works properly in PyCharm. When converted to an exe file it does not work.
This is traceback from the command line:
Traceback (most recent call last):
File "myscript.py", line 1, in <module>
import mysql.connector
ModuleNotFoundError: No module named 'mysql'
[8428] Failed to execute script 'myscript' due to unhandled exception!
The command to create the exe:
pyinstaller --onefile --console CoinVolumes.py
I also tried auto-py-to-exe but got the same error. Mysql is installed.
use this command:
pip install mysql-connector-python
after that verify:
$ python
Python 2.7.11 (default, Apr 26 2016, 13:18:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>>
In Python 3.6.9 I can use Pip 3 and do following:
pip3 install mysql
pip3 install mysql-connector-python
You would need to run the mysql server yourself. Pyinstaller is working properly, the problem here is that mysql server is not part of python, therefore you need to start the server mannualy. An alternative is to use sqlite, which does not require a server. It is built into standard python, no need for installing anything.

Can't import pyttsx in Python 2.7 on Ubuntu Linux 16

I'm trying to use pyttsx on Ubuntu Linux (64 bit, PC) with Python 2.7. I've successfully used pip to install the package
$sudo -H pip install pyttsx
$pip list
...
pyttsx (1.1)
...
When I try to import it the import call fails
$ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyttsx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyttsx
I'm not sure why I'm getting this. When I search for the question here on Stack Overflow I encounter one other instance about the same error message on a Raspberry Pi. But the solution mentioned there doesn't bring resolution on my PC so I don't think it is not related.
Any ideal what I am missing that is preventing the import from being successful?
Make sure your pip is tied to your python installation by checking both path's.
In Pip check:
`pip --version`
pip 9.0.1 from C:\Python27\lib\site-packages (python 2.7)
Later in python:
import sys
print sys.executable
C:\Python27\python.exe
run which pip, which python, make sure they are same suite
when run pip install, it should feedback the package is installed in which path
run this code in python
import sys
for i in sys.path:
print i
to check if your syspath including that path or not.

Import Error after pip install -e

I have cloned a repo (visdom) from github in order to make some contributions. In order to test my contributions, I tried to install the module within a conda env:
$ which pip
/home/jkarimi91/Apps/anaconda2/envs/visdom/bin/pip
$ pip install -e .
Running pip list shows that the module successfully installed:
visdom (0.1.4, /home/jkarimi91/Projects/visdom)
However, when I try to import the module, I receive an import error:
$ which python
/home/jkarimi91/Apps/anaconda2/envs/visdom/bin/python
$ python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import visdom
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named visdom
>>>
You could use the -t flag is used to tell pip to install the packages into a particular location, however, there actually appears to be an open issue with -t not playing nice with various other flags (and I just confirmed this for the repo in question). Work around this by installing with the git URL syntax, e.g. pip install git+git://github.com/facebookresearch/visdom.git#master#egg=visdom
As pointed out by Jmills comment, the path /home/jkarimi91/Projects/ was not in my python path. Also, as noted by #Jmills answer, using -t does not seem to be a viable option at the moment.
To fix this issue, I did the following:
$ pip uninstall visdom
$ pip install .
This approach needs to be repeated every time I make a change to the code but at least it works.

Using twisted on OS X Mavericks

I am trying to use twisted on OS X Mavericks, but I get this error message when I try to import it.
christohersmbp2:~ christopherspears$ python
Python 2.7.6 (default, Mar 8 2014, 09:29:01)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import twisted
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named twisted
My guess is that I am receiving this error because I am not using the default Python. I am using a Python installed with brew. Ideally, I would want to install twisted into a virtual environment to play with, but the docs are seriously lacking in details. Apparently, a dmg exists for Mac OS X 10.5, which is not helpful for me. I can install from the tarball into the virtual environment, but I am not sure how to do this. Any hints?
If you're using virtualenv, it doesn't matter whether you are using the system python or not.
Simply pip install twisted in your virtualenv, like:
$ workon MyTwistedEnv
$ pip install twisted
Currently, due to a bug in Xcode that affects all projects which contain extension modules, you may need to spell this
$ CFLAGS= pip install twisted
instead; hopefully this will be fixed soon. It may not affect brew installed Pythons, however.

Issue with Python Path. "ImportError: No module named setuptools"

I recently updated to Python 2.7 in order to start working with Django "Django requires Python, specifically Python 2.6.5 - 2.7.x."
As a result I needed to install some of the tools I have been using when I went through the excellent LPTHW Exercise 46
pip from http://pypi.python.org/pypi/pip
distribute from http://pypi.python.org/pypi/distribute
nose from http://pypi.python.org/pypi/nose/
virtualenv from http://pypi.python.org/pypi/virtualenv
Should be easy enough, I had done it all before...
When I run python in terminal I get the below. Note: Python 2.7.5
$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
When I type "which python" I get
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
However when I try to install distribute, nose or virtualenv I get the below error. Note Python/2.6
$ sudo pip install distribute
Exception:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/pip-1.3.1-py2.6.egg/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/Library/Python/2.6/site-packages/pip-1.3.1-py2.6.egg/pip/commands/install.py", line 258, in run
import setuptools
ImportError: No module named setuptools
Storing complete log in /Users/brendanspillane/Library/Logs/pip.log
localhost:~ brendanspillane$
I believe the Python/2.6 is the issue here. As a result i tried to set my Python Path (my first time) Using this question as a reference "changing python path on mac?" i typed in
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
This has no apparent effect.
However I am still not able to run sudo pip install distribute and keep getting the same error.
Can anyone help me? Is it my Python Path? or am I looking in the wrong direction?
Any help is as always, much appreciated.
Deepend
I'm not really sure how it worked but it did. #Robert Lujo deserves the up votes for his answer at https://stackoverflow.com/a/16511140/1214163
If the answer is also added here i will accept it.

Categories