0

I have Python 3.6 installed on my machine (Mac), and the Anaconda package as a whole. I am trying to run a simple script in PyCharm that looks like the following:

from selenium import webdriver
browser = webdriver.Firefox()
type(browser)
browser.get('http://inventwithpython.com')

When I run that I get the error message: 'Import error. No module named Selenium'.

EDIT: Here is the full stack trace that was requested below (Sorry, if this is not the full stack trace let me know):

Traceback (most recent call last): File "/Users/xxxx/PycharmProjects/StringsLoops/Selenium.py", line 1, in from selenium import webdriver ImportError: No module named 'selenium'

Process finished with exit code 1

I tried installing Selenium again using:

pip install selenium

and it installed successfully. I then ran my program again, same error. After some googling I tried:

python3 -m pip install selenium

That gave the following error:

'Requirement already satisfied: selenium in /Users/xxxx/anaconda/lib/python3.6/site-packages'

So I am lost at this point at what to do. I know a while back this used to work but that was before I:

A. upgraded OS to Mac OSX- Sierra

B. installed Anaconda (before I just had Python on my machine as a standalone and installed Selenium as a standalone)

Any ideas?

Thanks

6
  • Can you post the full stack trace? Commented Jul 12, 2017 at 4:05
  • @AetherUnbound I have added that to OP. I hope that is what you meant. Thanks Commented Jul 12, 2017 at 4:12
  • Is there any more information in the traceback or is it only one line? Commented Jul 12, 2017 at 4:15
  • @AetherUnbound that is all I am seeing in the console in PyCharm after execution, unless a full version of this trace is recorded and stored elsewhere? Commented Jul 12, 2017 at 4:17
  • 1
    No worries, it looks like that would be it. Can you try opening up a terminal and executing the following: python -c "from selenium import webdriver" and let me know what it says. Commented Jul 12, 2017 at 4:19

2 Answers 2

2

Since it sounds like your code is working properly in the terminal but not in PyCharm, it leads me to believe that PyCharm isn't properly configured. Try setting the default interpreter for PyCharm to the Anaconda python verson: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter-for-a-project.html.

Ideally, you should make a new environment and select "Add Local" when selecting your interpreter.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep, I think you are exactly right. I tried running this in TextWrangler and it worked fine. I'll need to check my PyCharm configuration. Thanks!
0

Hey I know this is a late reply but i figured out a way how you can fix this first of all the problem is within pycharm because if you already installed a module succefully that means IT'S INSTALLED !!! now for the solution : ---Go to files in the up-left corner scroll down and click on settings than look for a tab that says project:(your project name) click on that it will give you two options click on python interperter then choose your project name through the project interperter list after that you will see a "+" sign on your right hand side click on that then a tab will pop up than head over to the search bar above and type your package/module name which in this case is selenium then select it from the list presented and click on install package THAT'S IT !!!!!

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.