Request help on pexpect - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Request help on pexpect (/thread-28435.html) |
Request help on pexpect - rsurathu - Jul-19-2020 Dear All, Good Day. Please help / guide on how to get pexpect working, the following are the errors I am encountering. Appreciate if there is any reference guide provided on using pexpect. I am trying to write python code that is expected to run unix commands on several unix servers without having to manually enter userid/password on each server by using ssh (ssh -l user servername ; command etc). Thanks in advance. [e025711@IBBFDPLSPW010 python]$ python3 Python 3.6.8 (default, Sep 26 2019, 11:57:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pexpect Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pexpect' >>> RE: Request help on pexpect - rsurathu - Jul-19-2020 I already tried installing pexpect, but it didn't help [e025711@IBBFDPLSPW010 python]$ yum install pexpect Loaded plugins: product-id, search-disabled-repos, subscription-manager Skipping unreadable repository '/etc/yum.repos.d/rhel-dvd.repo' You need to be root to perform this command. [e025711@IBBFDPLSPW010 python]$ sudo su - Last login: Sun Jul 19 12:00:01 HKT 2020 [root@IBBFDPLSPW010 ~]# yum install pexpect Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Repository rhel-dvd is listed more than once in the configuration rhel-dvd | 2.8 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package pexpect.noarch 0:2.3-11.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pexpect noarch 2.3-11.el7 rhel-dvd 142 k Transaction Summary ================================================================================ Install 1 Package Total download size: 142 k Installed size: 784 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pexpect-2.3-11.el7.noarch 1/1 Verifying : pexpect-2.3-11.el7.noarch 1/1 Installed: pexpect.noarch 0:2.3-11.el7 Complete! [root@IBBFDPLSPW010 ~]# ls anaconda-ks.cfg [root@IBBFDPLSPW010 ~]# python3 Python 3.6.8 (default, Sep 26 2019, 11:57:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pexpect Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pexpect' >>> import pexpect.noarch Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pexpect' >>> Installed pexpect is successfully imported in python2 but not in python3, How can I get it working on python3? [root@IBBFDPLSPW010 ~]# python3 Python 3.6.8 (default, Sep 26 2019, 11:57:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pexpect Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pexpect' >>> import pexpect.noarch Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pexpect' >>> quit() [root@IBBFDPLSPW010 ~]# python2 Python 2.7.5 (default, Sep 26 2019, 13:23:47) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pexpect >>> RE: Request help on pexpect - snippsat - Jul-19-2020 When you do yum install pexpect it will install to Python 2.When you type python3 it start Python 3.6.8.So should use pip to install pexpect.python3 -m pip install --user pexpectAlso try pip3 -V command this should point to Python 3.6.May need to install it. python3.6 -m ensurepip # Or a repository that has it yum install --assumeyes python3-pipNow test with pip3 -V and it should point to 3.6.Example. pip3 -V pip 18.0 from /usr/local/lib/python3.6/site-packages/pip-18.0-py3.6.egg/pip (python 3.6)Then install to 3.6 would be. pip3 install --user pexpect RE: Request help on pexpect - rsurathu - Jul-19-2020 (Jul-19-2020, 08:51 AM)snippsat Wrote: When you do The server isn't connected to Internet, I mounted RHEL 7.8 DVD and using it as a repository. Received the following errors: [root@IBBFDPLSPW010 ~]# python3 -m pip install --user pexpect WARNING: Running pip install with root privileges is generally not a good idea. Try __main__.py install --user instead.Collecting pexpect Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fceb21ab9e8>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fceb21ab0b8>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fceb21ab400>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fceb21abc18>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fceb21aba90>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Could not find a version that satisfies the requirement pexpect (from versions: ) No matching distribution found for pexpect [root@IBBFDPLSPW010 ~]# echo $? 1 [root@IBBFDPLSPW010 ~]# python3.6 -m ensurepip WARNING: Running pip install with root privileges is generally not a good idea. Try __main__.py install --user instead.Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages Requirement already satisfied: pip in /usr/lib/python3.6/site-packages [root@IBBFDPLSPW010 ~]# yum install --assumeyes python3-pip Loaded plugins: product-id, search- : disabled-repos, : subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. rhel-dvd | 2.8 kB 00:00 Package python3-pip-9.0.3-5.el7.noarch already installed and latest version Nothing to do [root@IBBFDPLSPW010 ~]# [root@IBBFDPLSPW010 ~]# pip3 -V pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6) [root@IBBFDPLSPW010 ~]# pip3 install --user pexpect WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user instead.Collecting pexpect Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fefb1455d68>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fefb1455320>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fefb1455668>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fefb14552b0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fefb14554e0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pexpect/ Could not find a version that satisfies the requirement pexpect (from versions: ) No matching distribution found for pexpect [root@IBBFDPLSPW010 ~]# RE: Request help on pexpect - snippsat - Jul-19-2020 (Jul-19-2020, 02:19 PM)rsurathu Wrote: The server isn't connected to InterneTry download wheel from a other Pc,then move it over and then try to install with pip. pip3 install --user pexpect-4.8.0-py2.py3-none-any.whl |