-2

I got this error:

File "main.py", line 2
    python38 -m pip install selenium
                ^
SyntaxError: invalid syntax

It comes up when I try to run my code. I am using python on replit and have already imported pip on a previous line. Can anyone give me suggestions on what is wrong here?

RiveN
  • 2,595
  • 11
  • 13
  • 26
Cole
  • 1
  • 3
    That's a command for your OS command line, *not* something to put in a Python script. I doubt that this is something you can do on repl.it anyway, you'd need the code to be running locally so that it can control a browser also running on your machine. – jasonharper Oct 30 '21 at 21:18

1 Answers1

1

I used selenium on replit a few months ago and it does work, but it's not the smoothest experience (especially when you have a free tier).

Installing selenium on replit:

  1. You can install it by running python -m pip install selenium in shell (next to console)
  2. Make requirements.txt file, paste all required modules there and use this code with os.system method (which you can use to execute commands):
import os
os.system("python -m pip install -r requirements.txt")
  1. When you import selenium at the beginning in replit it should automatically download it, but if it doesn't then:
os.system("python -m pip install selenium")
RiveN
  • 2,595
  • 11
  • 13
  • 26