0

let me explain the problem:

I have pyCharm, SublimeText, CodeRunner, and IPython Notebook. I've been exploring each one to see which i like best. Turns out to be PyCharm.

Here's the problem - CodeRunner recognizes the package for "Selenium", and gladly imports the module.

However, when I use pyCharm and iPython notebook, an import error occurs - which befuddles me. Why would it work for one IDE and not the another?

Also - i used "sudo pip install selenium" in the terminal. What exactly is the root of the problem? I feel like it has something to do with permissions, but am not knowledgeable of how to modify permissions for python packages.

Thanks.

1 Answers1

0

In Pycharm you need to source the directory that contains the package Selenium.

In your project browser right-click a directory and select Mark directory as > source

eg:

/path/to/py/packages/Selenium/

You need to source the "packages" directory.

knittledan
  • 754
  • 2
  • 9
  • 23
  • I can find the package on the terminal - but can't find the folder for selenium or even a file name on pycharm to connect to – gryoswaim12 Nov 09 '14 at 20:20
  • ah, Go to Preferences > Project Structure then select "+ Add Content Root" to add the path to your Selenium package. Or add Selenium to a thirdParty directory in your project and source it. – knittledan Nov 09 '14 at 21:39
  • Thank you that helped! When I first started pycharm, I was under the impression that it indexed all the packages. I guess my question is why selenium was excluded whereas others were included. Let me know if you have ideas. – gryoswaim12 Nov 09 '14 at 22:32
  • Actually - it turns out it didn't help at all. When I use "from selenium import webdriver", it throws up an error. After running "print selenium.__file__", it stated the path: usr/local/lib/python2.7/site-packages/selenium/selenium.pyc. it should be the __init__ file instead. I removed selenium.pyc via the terminal per another really hard to find question on stckofw - it keeps popping up on the __file__. I used "sudo rm -rf selenium.pyc", and it goes straight to "selenium.py", which basically kills the entire module. What else should i do? – gryoswaim12 Nov 11 '14 at 03:28
  • pyc and pyo are python compiled files which are meant to speed up the execution of code. If the pyc file exists python with try to use it. If it doesn't python will try and create it. What's the error you're getting? – knittledan Nov 13 '14 at 19:50
  • Connected to pydev debugger (build 135.1057) Traceback (most recent call last): File "/Applications/PyCharm CE.app/helpers/pydev/pydevd.py", line 1733, in debugger.run(setup['file'], None, None) File "/Applications/PyCharm CE.app/helpers/pydev/pydevd.py", line 1226, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/Users/graysonswaim/Desktop/kk/Testing/mytestingproject.py", line 1, in from selenium import webdriver ImportError: cannot import name webdriver – gryoswaim12 Nov 14 '14 at 01:59
  • My previous comment looks muddled up - my apologies. The error I've been getting is that python is having a hard time recognizing the web driver. When i import this module on "Code Runner"(an IDE), it works just fine. But when I attempt to do the same on pyCharm, iPython, or sublime text, it doesn't work at all. So it seems like the more advanced IDE's have a hard time recognizing this particular module. – gryoswaim12 Nov 14 '14 at 02:02