DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • Code Search Using Retrieval Augmented Generation
  • GraalVM Features and Future
  • Implementing ROS Communication Patterns
  • Beyond Automation: How Artificial Intelligence Is Transforming Software Development

Trending

  • How Docker Desktop Enhances Developer Workflows and Observability
  • The Scrum Guide Expansion Pack
  • How to Achieve SOC 2 Compliance in AWS Cloud Environments
  • Designing Scalable Multi-Agent AI Systems: Leveraging Domain-Driven Design and Event Storming
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. How to Import From GitHub in Python

How to Import From GitHub in Python

Learn how to grab code directly from GitHub while in Python through an experimental package that utilizes new import hooks in PEP 302.

By 
Mike Driscoll user avatar
Mike Driscoll
·
Jun. 22, 16 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
8.7K Views

Join the DZone community and get the full member experience.

Join For Free

The other day, I came across this interesting experimental package for Python called import_from_github_com. The package uses the new import hooks provided in PEP 302 to basically allow you to import a package from github. What the package actually appears to do is install the package and add it to locals. You need Python 3.2 or greater, git and pip to use this package.

Once it’s installed, you can do the following:

>>> from github_com.zzzeek import sqlalchemy
Collecting git+https://github.com/zzzeek/sqlalchemy
  Cloning https://github.com/zzzeek/sqlalchemy to /tmp/pip-acfv7t06-build
Installing collected packages: SQLAlchemy
  Running setup.py install for SQLAlchemy ... done
Successfully installed SQLAlchemy-1.1.0b1.dev0
>>> locals()
{'__builtins__': <module 'builtins' (built-in)>, '__spec__': None,
 '__package__': None, '__doc__': None, '__name__': '__main__', 
'sqlalchemy': <module 'sqlalchemy' from '/usr/local/lib/python3.5/site-packages/sqlalchemy/__init__.py'>,
 '__loader__': <class '_frozen_importlib.BuiltinImporter'>}

One important note that isn’t mentioned on the package’s github page is that you need to run Python as an administrator or it won’t be able to install its packages. At least, this was true for me on Xubuntu. Anyway I thought this was a neat little package and demonstrates some of neat little import hooks that you can add to Python 3.

Python (language) GitHub

Published at DZone with permission of Mike Driscoll, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Code Search Using Retrieval Augmented Generation
  • GraalVM Features and Future
  • Implementing ROS Communication Patterns
  • Beyond Automation: How Artificial Intelligence Is Transforming Software Development

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: