SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to CassandraGokhan Atil
 
Plotly dash and data visualisation in Python
Plotly dash and data visualisation in PythonPlotly dash and data visualisation in Python
Plotly dash and data visualisation in PythonVolodymyr Kazantsev
 
The Evolution of the Hadoop Ecosystem
The Evolution of the Hadoop EcosystemThe Evolution of the Hadoop Ecosystem
The Evolution of the Hadoop EcosystemCloudera, Inc.
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless DatabasesDan Gunter
 
Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringShapeBlue
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version ControlJeremy Coates
 
Ceph Introduction 2017
Ceph Introduction 2017  Ceph Introduction 2017
Ceph Introduction 2017 Karan Singh
 
java-thread
java-threadjava-thread
java-threadbabu4b4u
 
Apache Hadoop YARN
Apache Hadoop YARNApache Hadoop YARN
Apache Hadoop YARNAdam Kawa
 
Ceph Performance and Sizing Guide
Ceph Performance and Sizing GuideCeph Performance and Sizing Guide
Ceph Performance and Sizing GuideJose De La Rosa
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Prashanth Kumar
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational DatabasesChris Baglieri
 

Was ist angesagt? (20)

Hadoop Overview kdd2011
Hadoop Overview kdd2011Hadoop Overview kdd2011
Hadoop Overview kdd2011
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Plotly dash and data visualisation in Python
Plotly dash and data visualisation in PythonPlotly dash and data visualisation in Python
Plotly dash and data visualisation in Python
 
Galera Cluster Best Practices for DBA's and DevOps Part 1
Galera Cluster Best Practices for DBA's and DevOps Part 1Galera Cluster Best Practices for DBA's and DevOps Part 1
Galera Cluster Best Practices for DBA's and DevOps Part 1
 
Spark
SparkSpark
Spark
 
The Evolution of the Hadoop Ecosystem
The Evolution of the Hadoop EcosystemThe Evolution of the Hadoop Ecosystem
The Evolution of the Hadoop Ecosystem
 
Apache HBase™
Apache HBase™Apache HBase™
Apache HBase™
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless Databases
 
Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uring
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 
Ceph Introduction 2017
Ceph Introduction 2017  Ceph Introduction 2017
Ceph Introduction 2017
 
java-thread
java-threadjava-thread
java-thread
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Apache Hadoop YARN
Apache Hadoop YARNApache Hadoop YARN
Apache Hadoop YARN
 
Ceph Performance and Sizing Guide
Ceph Performance and Sizing GuideCeph Performance and Sizing Guide
Ceph Performance and Sizing Guide
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
 
Hadoop
HadoopHadoop
Hadoop
 
GitHub Presentation
GitHub PresentationGitHub Presentation
GitHub Presentation
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational Databases
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 

Ähnlich wie Python virtualenv & pip in 90 minutes

5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenvamenasse
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvMarkus Zapke-Gründemann
 
Virtualenv
VirtualenvVirtualenv
VirtualenvWEBdeBS
 
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 2017Codemotion
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvMarkus Zapke-Gründemann
 
First python project
First python projectFirst python project
First python projectNeetu Jain
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolutionTatiana Al-Chueyr
 
10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftware10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftwareWilliam Hart
 
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.pdfCanditRoot
 
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 packagesHannes Hapke
 
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 OdooOdoo
 
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 2014Daniel Reis
 
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 & moreJacqueline Kazil
 
E D - Environmental Dependencies in Python
E D - Environmental Dependencies in PythonE D - Environmental Dependencies in Python
E D - Environmental Dependencies in PythonAdam Englander
 
Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Patrick Muehlbauer
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in pythonAndrés J. Díaz
 
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 GuideRapidValue
 
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)Yuriy Senko
 
Pip + virtualenv
Pip + virtualenvPip + virtualenv
Pip + virtualenvDaryl Yu
 

Ähnlich wie 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
 

Mehr von Larry Cai

Learn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLearn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLarry Cai
 
Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for JenkinsLarry Cai
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLarry Cai
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90minsLarry Cai
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in dockerLarry Cai
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer TalkLarry Cai
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90minsLarry Cai
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using dockerLarry Cai
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90minsLarry Cai
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutesLarry Cai
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLarry Cai
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90minsLarry Cai
 
Lead changes in software development
Lead changes in software developmentLead changes in software development
Lead changes in software developmentLarry Cai
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90minsLarry 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 ExampleLarry Cai
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examplesLarry Cai
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdownLarry Cai
 
Continuous Integration Introduction
Continuous Integration IntroductionContinuous Integration Introduction
Continuous Integration IntroductionLarry Cai
 
Agile & ALM tools
Agile & ALM toolsAgile & ALM tools
Agile & ALM toolsLarry Cai
 

Mehr von 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
 

Kürzlich hochgeladen

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
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.pdfAdmir Softic
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 

Kürzlich hochgeladen (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
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
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

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