Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Everytime i run my script i get:

  File "./", line 35, in <module>
  import npyscreen
ImportError: No module named npyscreen

Here is my code. It checks to see if mypyscreen is installed. if not then install it then import. if it is then import. But instead its giving me an error.

# Installing npyscreen before importing npyscreen for menu UI
npy ='locate npyscreen-3.2.egg-info'))
if npy == '1':
    os.chdir('/opt/')'sudo wget$'tar xvf npyscreen-3.37.tar.gz'))
    os.chdir('npyscreen-3.2')'sudo ./'))'sudo rm npyscreen-3.37.tar.gz'))

import npyscreen
share|improve this question

According to 7-Zip on Windows, there is a in the archive, but there is no 3.2 Directory, I have / in the root, also, the path to setup is:


os.chdir('/opt/'), puts you in /opt
wget, would download the tar into /opt
tar xvf npyscreen-3.37.tar.gz, should untar the package, in /opt
os.chdir('npyscreen-3.2') should be:


sudo ./
enter code here
sudo rm npyscreen-3.37.tar.gz
echo "Download and Install Finished."
import npyscreen
share|improve this answer

I don't like it to install packages without telling the user, but this is how I should do it:

    import npyscreen
except ImportError:
    # Package not found, install it
    import subprocess["sudo", "pip", "install", "npyscreen"])
    #TODO: check the return code for errors
    import npyscreen
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.