-1

I am trying to clone a git repo in Python but I am getting an invalid syntax error. Here is my code so far:

import pickle
import os
if not os.path.exists('secret_petfinder_credentials.pkl'):
Petfinder={}
Petfinder['Consumer Key']='mykey'
Petfinder['Consumer Secret']='mysecret'
   with open('secret_petfinder_credentials.pkl','wb') as f: 
       pickle.dump(Petfinder, f)
else: 
   Petfinder=pickle.load(open('secret_petfinder_credentials.pkl','rb'))
!pip install petfinder
git clone git://github.com/gtaylor/petfinder-api.git`
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
Sam P
  • 113
  • 1
  • 4
  • 8

1 Answers1

1

If you really need to clone from your python script, consider GitPython, and its clone_from() function:

from git import Repo

Repo.clone_from(git_url, repo_dir)

Or pygit2, and its clone_repository() function.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I did the following: `from git import Repo Repo.clone_from('https://github.com/gtaylor/petfinder-api', 'repo_dir1') import petfinder` And am getting an error: Missing parenthesis in call to 'print' – Sam P Jul 24 '17 at 13:55
  • @SamP Check your version of Python: https://stackoverflow.com/a/25445440/6309, https://stackoverflow.com/a/25445440/6309. It should probably be python 2 for the code/example to work. – VonC Jul 25 '17 at 06:17