How to Install and Use Python Pip on Ubuntu 14.04 and pip install pytz
3451 단어 python
import pytz
import datetime
tz = pytz.timezone('Asia/Shanghai')
cur_date = datetime.datetime.now(tz).strftime('%Y-%m-%d %H:%M:%S')
print cur_date
python 시간 대 설정 - pytz 모듈:http://blog.csdn.net/starrain00/article/details/18323807
Introduction
Pip (Pip installs packages) is a package management tool used to install and manage programs written in Python. PyPa also recommends the use of Pip for installing and managing packages.
In this tutorial we will discuss how to install Pip on Ubuntu 14.04 and how to use Pip to install and manage commands.
Installing Pip
Python pip package is available on Ubuntu apt-get package repository. But before we can install pip, we have to install necessary packages to run pip.
# sudo apt-get update
# sudo apt-get install python-dev build-essential
Now we can install Pip using the following command:
# sudo apt-get install python-pip
However the pip version included on Ubuntu apt-get can be outdated, we can upgrade pip to latest version by using command below.
# pip install --upgrade pip
Basic usage
Now that we have the latest version of pip installed, let's take a look at some commands that we can use to manage packages.
Installing packages using pip is easy, following is the command syntax that is used to install packages using pip.
# pip install
It is also possible to specify an exact or minimum package version using the command syntax below.
# pip install package==1.5
# pip install package>=1.5
Upgrading a package using pip is done by use of the the argument
--upgrade
as we did when upgrading pip to the latest version. # pip install --upgrade
As much fun can Installing new packages be, we sadly sometimes have to uninstall packages too, we can uninstall packages using the command:
# pip uninstall
More useful usage
Now that we have the basic of pip covered, let's take a look at what other things we can do with pip.
Search
If you ever forget a name of a package or need to look up if a package exists, you can search pip repository by using the following command:
# pip search
Show
Show is used to find information such as version, author on a given installed package.
$sudo pip install pytz
# pip show pytz
---
Metadata-Version: 1.1
Name: pytz
Version: 2013.7
Summary: World timezone definitions, modern and historical
Home-page: http://pythonhosted.org/pytz
Author: Stuart Bishop
Author-email: [email protected]
License: MIT
List
We can also list all installed python packages including editables by using the following command. Packages are listed in a case-insensitive sorted order.
# pip list
Conclusion
Most python modules are available on pip and pip simplifies the process of installing and managing python modules. Pip is a very useful package management program that every python developer needs to and should know how to use.
source: https://syscoding.com/tutorials/27/how-to-install-and-use-python-pip-on-ubuntu-1404/
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.