云网牛站
所在位置:首页 > Linux教程 > 给在Linux虚拟机里运行的FreeBSD 12安装pip Python包管理器

给在Linux虚拟机里运行的FreeBSD 12安装pip Python包管理器

2019-03-06 16:10:15作者:戴均益稿源:云网牛站

本文介绍在FreeBSD 12上安装pip Python包管理器、升级pip的方法,系统是运行在Linux虚拟机VirtualBox里的,可参考在Ubuntu 18.04/Debian 9上安装VirtualBox 6.0的方法

 

FreeBSD 12上安装pip Python包管理器

目前有两种方法可以在FreeBSD系统上安装pip,我的笔记本电脑上安装了FreeBSD 12系统:

# freebsd-version

12.0-RELEASE

FreeBSD 12自带有Python2.7和Python3.6:

# python

python2.7 python2.7-config python3.6 python3.6-config python3.6m python3.6m-config

我使用的默认版本是Python3.6,请注意,FreeBSD 12系统上没有python命令:

# which python

python: Command not found

你可以创建Python3.6二进制文件到/usr/local/bin/python的符号链接:

# ln -s /usr/local/bin/python3.6 /usr/local/bin/python

# python --version

Python 3.6.6

从py36-pip包安装Pip:

# pkg install py36-pip

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

py36-pip: 9.0.3

py36-setuptools: 40.0.0

Number of packages to be installed: 2

The process will require 21 MiB more space.

6 MiB to be downloaded.

Proceed with this action? [y/N]: y

[1/2] Fetching py36-pip-9.0.3.txz: 100%    6 MiB 308.7kB/s    00:20

[2/2] Fetching py36-setuptools-40.0.0.txz: 100%  487 KiB 124.6kB/s    00:04

Checking integrity... done (0 conflicting)

[1/2] Installing py36-setuptools-40.0.0...

[1/2] Extracting py36-setuptools-40.0.0: 100%

[2/2] Installing py36-pip-9.0.3...

[2/2] Extracting py36-pip-9.0.3: 100%

Message from py36-setuptools-40.0.0:

Only /usr/local/bin/easy_install-3.6 script has been installed

since Python 3.6 is not the default Python version.

Message from py36-pip-9.0.3:

================ !!!! WARNING !!!! ================

pip MUST ONLY be used:

* With the --user flag, OR

* To install or manage Python packages in virtual environments

Failure to follow this warning can and will result in an inconsistent

system-wide Python environment (LOCALBASE/lib/pythonX.Y/site-packages) and

cause errors.

Avoid using pip as root unless you know what you're doing.

================ !!!! WARNING !!!! ================

为Pip-3.6包创建一个符号链接:

# which pip-3.6

/usr/local/bin/pip-3.6

# ln -s /usr/local/bin/pip-3.6 /usr/local/bin/pip

# pip --version 

pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)

升级pip:

# pip install --upgrade pip

Collecting pip

Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB) 100% |###########################| 1.3MB 750kB/s

Installing collected packages: pip

Found existing installation: pip 9.0.3

Uninstalling pip-9.0.3:

Successfully uninstalled pip-9.0.3

Successfully installed pip-18.1

测试pip使用情况:

$ pip install awscli --user

如果你使用Pip作为普通用户安装Python包,则将二进制文件放在.local/bin/下。

将路径添加到PATH变量:

$ vim ~/.bashrc

export PATH=$PATH:.local/bin/

如果要安装Pip for Python 2.7,请运行:

# pkg install py27-pip

至此,已全面成功的在FreeBSD 12系统上安装PIP Python包管理器了。

 

相关主题

在Ubuntu 18.04系统上使用Pip3来安装Django

精选文章
热门文章