SlideShare a Scribd company logo
1 of 13
Larry cai <larry.caiyu#gmail.com>
Agenda
Python Virtualenv & Pip in 90 minutes2
 What isVirtualenv & Pip ?
 Environment : InstallVirtualenv on windows (Linux is
easy)
 Exercise 1: Create own environment using virtualenv
 Exercise 2: Learn pip command
 Exercise 3: Create own Pip package
 Exercise 4: Make scripts runnable directly
 Bonus Exercise: Share your scripts outside
!!!! Exercise are created by me, and some introduction slides are
copied from http://www.slideshare.net/webdebs/virtualenv-12727213
Problem for using python
 How to install the packages ?
(download & python setup.py install)
 How to use different python versions (2.6,2.7,3.x..)?
 How to install different packages (0.2,0.3.)
 How to test some packages without ruin the system
 How to delivery your python codes to other ?
 How to verify them ?
 …
Python Virtualenv & Pip in 90 minutes3
What is Pip & PyPi & Virtualenv
 pip is a tool for installing and managing Python packages 
 It’s a replacement for easy_install.
 PyPi (Python Pakage Index) is a repository of software for
Python and currently count 33429 package
 https://pypi.python.org/pypi
 Virtualenv is a tool to isolate your python environment
Python Virtualenv & Pip in 90 minutes4
Environment
Python Virtualenv & Pip in 90 minutes5
 Python 2.7.x In Windows with Git Bash
 http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi (2.7.5
has issues with pycrypto)
 Add into Path
 Install Pip (Python package management)
 curl -O http://python-distribute.org/distribute_setup.py
 python distribute_setup.py
 easy_install pip
 InstallVirtualenv
 pip --version
 pip install virtualenv
http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows
WHY virtual environments ?
 Isolation - Python packages and even version live in their
own planet :)
 Permissions - No sudoers, the environment is mine!!!
 Organization - each project can maintain its own
requirements file of Python packages.
 No-Globalization – don’t require installing stuff globally
on the system.
Python Virtualenv & Pip in 90 minutes6
Exercise 1: Create own environment
Python Virtualenv & Pip in 90 minutes7
 Create own environment
$ pip list # if error, $ pip install --upgrade setuptools
$ cd ~
$ virtualenv venv
$ find venv
$ . venv/Scripts/activate
$ pip list
$ pip install python-jenkins xunitparser
$ pip list
$ find ~/venv | grep unit
$ deactivate
$ pip list
Exercise 2: learn pip
 Install , uninstall, upgrade packages
$ . ~/venv/Scripts/activate
$ pip install junit-xml # latest version
$ pip uninstall junit-xml
$ pip install junit-xml==1.2 # specific version
$ pip install --upgrade junit-xml
 Generate package list and restore
$ pip list
$ pip freeze > requirements.txt
$ pip uninstall junit-xml xunitparser
$ pip install -r requirements.txt
 Install local packages from mirror
$ pip install --index-url http://my.package.repo/simple/ <yourpackage>
Python Virtualenv & Pip in 90 minutes8
http://www.pip-installer.org/en/latest/usage.html
Exercise 3: Create your own package
 Write a simple hello.py under hello folder
print “hello world”
 Write a setup.py
from distutils.core import setup
setup(name=‘hello',
version=‘0.0.1',
py_modules=[‘hello'], )
 Package and install
$ python setup.py sdist
$ pip install dist/hello.0.0.1.zip
$ find ~/venv | grep hello
 Change version to “0.0.2” and do it again
Python Virtualenv & Pip in 90 minutes9
http://docs.python.org/2/distutils/introduction.html
Exercise 4: make your scripts runnable
 Make the hello.py can be runnable after installation
from distutils.core import
setup setup(name=‘hello',
version=‘0.0.3’,
scripts=[‘hello.py’],
py_modules=[‘hello'], )
 Testing it
$ python setup.py sdist
$ pip install dist/hello.0.0.3.zip
$ find ~/venv | grep hello
 Make it runnable (change hello.py ..)
$ hello.py # bingo, so simple
Python Virtualenv & Pip in 90 minutes10
Bonus: Share your scripts outside
 https://pypi.python.org/pypi register and
$ python setup.py register sdist upload # that’s all
 Simpler than your thinking ….
Python Virtualenv & Pip in 90 minutes11
Summary
 Using virtualenv to isolate your python environment
 Use pip to package
 Host in github and shared in PyPi repository
 Enjoy python programming
Python Virtualenv & Pip in 90 minutes12
Reference
 Slides
 http://www.slideshare.net/webdebs/virtualenv-12727213
 Usage link
 http://www.pip-installer.org/en/latest/usage.html
 https://pypi.python.org/pypi
 http://docs.python.org/2/distutils/introduction.html
 https://pypi.python.org/pypi/virtualenv
Python Virtualenv & Pip in 90 minutes13

More Related Content

What's hot

버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
민태 김
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
Rohit Kumar
 

What's hot (20)

Introduction git
Introduction gitIntroduction git
Introduction git
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Vi editor
Vi editorVi editor
Vi editor
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
An Introduction to MongoDB Ops Manager
An Introduction to MongoDB Ops ManagerAn Introduction to MongoDB Ops Manager
An Introduction to MongoDB Ops Manager
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
MongoDB Atlas Data Lake 집중 분석 [MongoDB]
MongoDB Atlas Data Lake 집중 분석 [MongoDB]MongoDB Atlas Data Lake 집중 분석 [MongoDB]
MongoDB Atlas Data Lake 집중 분석 [MongoDB]
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introducing GitLab
Introducing GitLabIntroducing GitLab
Introducing GitLab
 
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 

Similar to Python virtualenv & pip in 90 minutes

5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenv
amenasse
 
Using the pip package manager for Odoo
Using the pip package manager for OdooUsing the pip package manager for Odoo
Using the pip package manager for Odoo
Odoo
 

Similar to Python virtualenv & pip in 90 minutes (20)

Virtualenv
VirtualenvVirtualenv
Virtualenv
 
5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenv
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
First python project
First python projectFirst python project
First python project
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
 
10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftware10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftware
 
How to Install Odoo 17 on Ubuntu.pdf
How to Install Odoo 17 on Ubuntu.pdfHow to Install Odoo 17 on Ubuntu.pdf
How to Install Odoo 17 on Ubuntu.pdf
 
Share your code with the Python world by
 creating pip packages
Share your code with the Python world by
 creating pip packagesShare your code with the Python world by
 creating pip packages
Share your code with the Python world by
 creating pip packages
 
Using the pip package manager for Odoo
Using the pip package manager for OdooUsing the pip package manager for Odoo
Using the pip package manager for Odoo
 
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
 
Django district pip, virtualenv, virtualenv wrapper & more
Django district  pip, virtualenv, virtualenv wrapper & moreDjango district  pip, virtualenv, virtualenv wrapper & more
Django district pip, virtualenv, virtualenv wrapper & more
 
E D - Environmental Dependencies in Python
E D - Environmental Dependencies in PythonE D - Environmental Dependencies in Python
E D - Environmental Dependencies in Python
 
Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
AWS EC2 Ubuntu Instance - Step-by-Step Deployment GuideAWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
 
Pip + virtualenv
Pip + virtualenvPip + virtualenv
Pip + virtualenv
 

More from Larry Cai

Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
Larry Cai
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
Larry Cai
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by Example
Larry Cai
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examples
Larry Cai
 

More from Larry Cai (20)

Learn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLearn kubernetes in 90 minutes
Learn kubernetes in 90 minutes
 
Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for Jenkins
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in docker
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90mins
 
Lead changes in software development
Lead changes in software developmentLead changes in software development
Lead changes in software development
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by Example
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examples
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
Continuous Integration Introduction
Continuous Integration IntroductionContinuous Integration Introduction
Continuous Integration Introduction
 
Agile & ALM tools
Agile & ALM toolsAgile & ALM tools
Agile & ALM tools
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Python virtualenv & pip in 90 minutes

  • 2. Agenda Python Virtualenv & Pip in 90 minutes2  What isVirtualenv & Pip ?  Environment : InstallVirtualenv on windows (Linux is easy)  Exercise 1: Create own environment using virtualenv  Exercise 2: Learn pip command  Exercise 3: Create own Pip package  Exercise 4: Make scripts runnable directly  Bonus Exercise: Share your scripts outside !!!! Exercise are created by me, and some introduction slides are copied from http://www.slideshare.net/webdebs/virtualenv-12727213
  • 3. Problem for using python  How to install the packages ? (download & python setup.py install)  How to use different python versions (2.6,2.7,3.x..)?  How to install different packages (0.2,0.3.)  How to test some packages without ruin the system  How to delivery your python codes to other ?  How to verify them ?  … Python Virtualenv & Pip in 90 minutes3
  • 4. What is Pip & PyPi & Virtualenv  pip is a tool for installing and managing Python packages   It’s a replacement for easy_install.  PyPi (Python Pakage Index) is a repository of software for Python and currently count 33429 package  https://pypi.python.org/pypi  Virtualenv is a tool to isolate your python environment Python Virtualenv & Pip in 90 minutes4
  • 5. Environment Python Virtualenv & Pip in 90 minutes5  Python 2.7.x In Windows with Git Bash  http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi (2.7.5 has issues with pycrypto)  Add into Path  Install Pip (Python package management)  curl -O http://python-distribute.org/distribute_setup.py  python distribute_setup.py  easy_install pip  InstallVirtualenv  pip --version  pip install virtualenv http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows
  • 6. WHY virtual environments ?  Isolation - Python packages and even version live in their own planet :)  Permissions - No sudoers, the environment is mine!!!  Organization - each project can maintain its own requirements file of Python packages.  No-Globalization – don’t require installing stuff globally on the system. Python Virtualenv & Pip in 90 minutes6
  • 7. Exercise 1: Create own environment Python Virtualenv & Pip in 90 minutes7  Create own environment $ pip list # if error, $ pip install --upgrade setuptools $ cd ~ $ virtualenv venv $ find venv $ . venv/Scripts/activate $ pip list $ pip install python-jenkins xunitparser $ pip list $ find ~/venv | grep unit $ deactivate $ pip list
  • 8. Exercise 2: learn pip  Install , uninstall, upgrade packages $ . ~/venv/Scripts/activate $ pip install junit-xml # latest version $ pip uninstall junit-xml $ pip install junit-xml==1.2 # specific version $ pip install --upgrade junit-xml  Generate package list and restore $ pip list $ pip freeze > requirements.txt $ pip uninstall junit-xml xunitparser $ pip install -r requirements.txt  Install local packages from mirror $ pip install --index-url http://my.package.repo/simple/ <yourpackage> Python Virtualenv & Pip in 90 minutes8 http://www.pip-installer.org/en/latest/usage.html
  • 9. Exercise 3: Create your own package  Write a simple hello.py under hello folder print “hello world”  Write a setup.py from distutils.core import setup setup(name=‘hello', version=‘0.0.1', py_modules=[‘hello'], )  Package and install $ python setup.py sdist $ pip install dist/hello.0.0.1.zip $ find ~/venv | grep hello  Change version to “0.0.2” and do it again Python Virtualenv & Pip in 90 minutes9 http://docs.python.org/2/distutils/introduction.html
  • 10. Exercise 4: make your scripts runnable  Make the hello.py can be runnable after installation from distutils.core import setup setup(name=‘hello', version=‘0.0.3’, scripts=[‘hello.py’], py_modules=[‘hello'], )  Testing it $ python setup.py sdist $ pip install dist/hello.0.0.3.zip $ find ~/venv | grep hello  Make it runnable (change hello.py ..) $ hello.py # bingo, so simple Python Virtualenv & Pip in 90 minutes10
  • 11. Bonus: Share your scripts outside  https://pypi.python.org/pypi register and $ python setup.py register sdist upload # that’s all  Simpler than your thinking …. Python Virtualenv & Pip in 90 minutes11
  • 12. Summary  Using virtualenv to isolate your python environment  Use pip to package  Host in github and shared in PyPi repository  Enjoy python programming Python Virtualenv & Pip in 90 minutes12
  • 13. Reference  Slides  http://www.slideshare.net/webdebs/virtualenv-12727213  Usage link  http://www.pip-installer.org/en/latest/usage.html  https://pypi.python.org/pypi  http://docs.python.org/2/distutils/introduction.html  https://pypi.python.org/pypi/virtualenv Python Virtualenv & Pip in 90 minutes13