-1

I tried this pip install:

pip install https://github.com/rapptz/discord.py

I get the error 'SyntaxError: Invalid Syntax'.

Can I install from GitHub using pip?

H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144

3 Answers3

2

This package seems to be only for python 3.x. so just type the following command:

sudo python3 -m pip install git+https://github.com/rapptz/discord.py

The meaning of this command:

  1. python3 -m is to specify the python version.
  2. pip install git+https:[URL] is for git repos.
  3. Note that point 2 can also be:pip install git+git:[URL] or pip install --upgrade https:[URL].
0

pip is a command line utility outside of python.

Run pip install https://github.com/rapptz/discord.py on your terminal, not inside a python REPL.

Jerome Indefenzo
  • 967
  • 6
  • 25
  • where do i find the terminal – Jake Bamford Oct 20 '16 at 17:13
  • what OS are you using? – Jerome Indefenzo Oct 20 '16 at 17:16
  • If you don't have pip yet, [look here](http://www.pip-installer.org/en/latest/installing.html) fo instructions on how to install it. After installing it, [open the command prompt](http://www.howtogeek.com/235101/10-ways-to-open-the-command-prompt-in-windows-10/) and run `pip install https://github.com/rapptz/discord.py`. – Jerome Indefenzo Oct 20 '16 at 17:19
  • Also, check this question out: http://stackoverflow.com/questions/20101834/pip-install-from-github-repo-branch for some more info on cloning git repos with `pip` – Cameron Hurd Oct 20 '16 at 17:20
0

This seems like XY problem

You asked how to install python packages from GitHub using pip, whereas the real question is why bash commands don't work in python console.

The difference

These two languages have different syntax, so you can't do that. There are two simple solutions for this:

  1. Use os module to run console commands:
import os
os.system("pip install https://github.com/rapptz/discord.py")

This solution has a downside: This is unnecessary complex. The second solution solves it:

  1. Use different tool.

Close python terminal/console/file you have open. Open bash (or any other installed console) and then run

pip install https://github.com/rapptz/discord.py
oBrstisf8o
  • 124
  • 10