Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
720 views
in Technique[技术] by (71.8m points)

git - Import a Python library from Github

I'm new to Python so this may sound silly.

I want to use a Python library I've found on Github, lets say on https://github.com/praw-dev/praw, and I want to be able to do git pull in the future to pull the latest commits.

Question: Should I git clone <git url> in the project directory and delete everything except the praw directory, then in my python script do a import praw?

In iPython,

import praw

gives the error ImportError: No module named praw

Directory Structure

~myProject
    praw
    myNotebook.ipynb
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Actually, if given package is not on PyPI (or you want a specific branch) you can still install it through pip from GitHub with:

pip install git+https://github.com/[repo owner]/[repo]@[branch name]

And for your problem it would be (although @pandita's answer is correct for normal usage case):

pip install git+https://github.com/praw-dev/praw.git

For more information check this answer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...