1

I am coding on Sublime Text. I have selenium installed and I keep getting an error. Here is my code:

from selenium import webdriver

driver = webdriver.Chrome(executable_path='/Users/dylansiegel/Desktop/chromedriver')
driver.get('https://www.supremenewyork.com/shop/all/shirts')

#driver.find_element_by_partial_link_text('Quilted Plaid Zip Up Shirt').click()

I am continually getting this error when I try to build:

Traceback (most recent call last):

File "/Users/dylansiegel/Desktop/bot.py", line 1, in from selenium import webdriver

ImportError: No module named selenium

[Finished in 0.1s with exit code 1]

[shell_cmd: python -u "/Users/dylansiegel/Desktop/bot.py"]

[dir: /Users/dylansiegel/Desktop]

[path: /Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public]

Dylan Siegel
  • 33
  • 1
  • 7

1 Answers1

0

First, you'd want to check which version of python is being used from your terminal.

This command would return the path/version: which python

Then you'd want to add that into a shebang at the top of your script using #!PATH python, like #!/usr/bin/env python.

Now try to run your script from the terminal again and it should work.

If it doesn't, then try to install selenium again using either:

sudo pip3 install selenium or sudo pip install selenium.

isopach
  • 1,783
  • 7
  • 31
  • 43
  • When I type this commands it does nothing or gives me an error. Using `sudo pip3 install selenium` I get this error code: – Dylan Siegel Dec 05 '19 at 16:19
  • WARNING: The directory '/Users/dylansiegel/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. WARNING: The directory '/Users/dylansiegel/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. – Dylan Siegel Dec 05 '19 at 16:19
  • Requirement already satisfied: selenium in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (3.141.0) Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from selenium) (1.25.7) – Dylan Siegel Dec 05 '19 at 16:19
  • @DylanSiegel Does the linked question work for you? Hope you've gotten the solution. – isopach Dec 06 '19 at 04:19
  • I now deleted all of the files I was having trouble with: Python, selenium, and homebrew. I now reinstalled home-brew and python, but pip3 won't work. Using the command `easy_install pip` doesn't work either. I got an error code which you can see below: – Dylan Siegel Dec 06 '19 at 04:34
  • error: can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-28346.pth' The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: /Library/Python/2.7/site-packages/ – Dylan Siegel Dec 06 '19 at 04:35
  • Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://pythonhosted.org/setuptools/easy_install.html Please make the appropriate changes for your system and try again. – Dylan Siegel Dec 06 '19 at 04:35
  • @DylanSiegel Could you make a new question for the pip3 problem you're having? I think that's an entirely different problem from this. – isopach Dec 06 '19 at 05:29
  • Yes I already did @Yuu I will @ you in the comments. – Dylan Siegel Dec 06 '19 at 06:44