How to Install and Use Python Pip on Ubuntu 14.04 and pip install pytz

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 <package>

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 <package>

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 <package>

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 <search query>
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: stuart@stuartbishop.net
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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值