0

I am trying to run a small program from the command line under Linux. The program runs correctly when I use IDLE but I cant run it from the command line. I ran this little program to tell me my path:

import sys
print sys.path

Under IDLE I have the following entry:

/usr/local/lib/python2.7/dist-packages 
/usr/lib/python2.7/dist-packages

These entries are not there when I run under the command line. The package that I need to import (selenium) is in dist-packages. I get the following error when trying to import selenium.

from selenium import webdriver
...
ImportError: No module named selenium

I have tried pip install selenium, pip uninstall selenium, doesnt fix the problem. When I try python setup.py install (on the selenium install file) I get:

error: invalid command 'easy_install'

How can I solve this problem - do I have to add: /usr/local/lib/python2.7/dist-packages to my path, and if so how do I do that?

1 Answer 1

1

You can just do one of the following:

1.Add the path to sys.path

import sys
sys.path.append('/usr/local/lib/python2.7/dist-packages')

2.Add to PYTHONPATH from commandline

export PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.