pip install selenium ERROR python 3.7 Windows 10

10,678

Solution 1

You are typing into Python shell.

To leave the interactive shell and go back to the console (the system shell), press Ctrl-Z and then Enter on Windows, or Ctrl-D on OS X or Linux. Alternatively, you could also run the python command exit().

Then type into Command line Interface.

By the way I believe you need to install using pip3 rather than pip, since you are using python3.X. So command would be

pip3 install -U selenium

Solution 2

python -m pip install selenium --user

pip defaults to installing Python packages to a system directory (such as /usr/local/lib/python3.4). This requires root access.

--user makes pip install packages in your home directory instead, which doesn't require any special privileges.

Share:
10,678

Related videos on Youtube

Travis Smith
Author by

Travis Smith

Web developer, college kid.

Updated on June 04, 2022

Comments

  • Travis Smith
    Travis Smith about 2 years

    I downloaded Python 3.7 just now. Now I'm trying to install the selenium module. I am able to run python in my command prompt. But, when I type:

    pip install -U selenium
    

    or

    pip install selenium
    

    I get a syntax error.

    Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> pip install -U selenium
      File "<stdin>", line 1
        pip install -U selenium
                  ^
    SyntaxError: invalid syntax
    

    I'm thinking it's a bug with the new Python version, but not sure if anybody can tell me what I did wrong.

    • Mufeed
      Mufeed almost 6 years
      I guess you are typing into Python shell
    • Mufeed
      Mufeed almost 6 years
      Exit from Python shell and type into terminal.
    • Anshuman Sharma
      Anshuman Sharma almost 6 years
      type in cmd prompt, not python shell, have you already install pip in your windows? if not first you need to install then run your command
  • raviraja
    raviraja almost 6 years
    why user should go to that location? it will be already under environment variables, the issue here is user is trying in python shell instead of command line.
  • mahesh
    mahesh almost 6 years
    issue is correct but not sure if he added it in env variables, so easy way to move to location and run.
  • raviraja
    raviraja almost 6 years
    If the environment variables is the issue, the error would have been different.
  • mahesh
    mahesh almost 6 years
    for windows env you need to move to location for pip, for shell its acceptable
  • colidyre
    colidyre over 4 years
    Hello Furkan. Welcome to StackOverflow. It would be helpful for all readers if you explain your answer a bit. Just providing a code snippet can be helpful and in rare cases it's enough. But here I miss an explanation why this should work and why the OP has problems with his approach.