Can't find package Expect while executing "package require Expect"

I want to use autoexpect for a simple .sh file but the terminal shows this error:

can't find package Expect
    while executing
"package require Expect"
    (file "/usr/bin/autoexpect" line 6)

my terminal command is:

autoexpect shell.sh

I remove expect and install it again but no difference with past!

Can anyone help me?

already newest version

This is output of dpkg -l | grep tcl; which tclsh; which tclsh8.6; dpkg -S Expect; echo $PATH. Does Anaconda contradict expect?

installed, anaconda path


Solution 1:

You have to install the main Expect package by

sudo apt-add-repository universe
sudo apt-get install expect

and it will install tcl-expect as dependency for you.

To run Expect scripts avoiding problems with Anaconda you have to manually specify PATH variable and then run your expect/tcl script:

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
autoexpect ./shell.sh

or in one line:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin autoexpect ./shell.sh

To ease every autoexpect command execution you can add the following alias to the ~/.bashrc:

alias autoexpect='PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin autoexpect'