linux服务器怎么安装pip

linux服务器怎么安装pip,第1张

1、先说一下什么是pip

pip 是“A tool for installing and managing Python packages.”,也就是说pip是python的软件安装工具

2、下面介绍怎么在linux下安装pip

下载pip到/usr/local/src

# cd /usr/local/src

# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate

如果提示:-bash: wget: command not found

那么安装wget,执行如下:

# yum -y install wget

解夺安装pip

# tar -xzvf pip-1.5.4.tar.gz

# cd pip-1.5.4

# python setup.py install

如果安装报下面的错:

Traceback (most recent call last):

File "setup.py", line 6, in <module>

from setuptools import setup, find_packages

ImportError: No module named setuptools

那么就要先安装setuptools包

(1)下载setuptools包

# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz

(2)解压setuptools包

# tar zxvf setuptools-2.0.tar.gz

# cd setuptools-2.0

(3)编译setuptools

# python setup.py build

(4)开始执行setuptools安装

# python setup.py install

安装完成setuptools包后,在重新执行:

# cd /usr/local/src/pip-1.5.4

# python setup.py install

至此pip安装完成

3、linux下pip使用参数

# pip --help

Usage:

pip <command>[options]

Commands:

install Install packages.

uninstall Uninstall packages.

freeze Output installed packages in requirements format.

listList installed packages.

showShow information about installed packages.

search Search PyPI for packages.

wheel Build wheels from your requirements.

zip DEPRECATED. Zip individual packages.

unzip DEPRECATED. Unzip individual packages.

bundle DEPRECATED. Create pybundles.

helpShow help for commands.

General Options:

-h, --help Show help.

-v, --verbose Give more output. Option is additive, and can be used up to 3 times.

-V, --version Show version and exit.

-q, --quiet Give less output.

--log-file <path> Path to a verbose non-appending log, that only logs failures. This log is active by default at /root/.pip/pip.log.

--log <path> Path to a verbose appending log. This log is inactive by default.

--proxy <proxy>Specify a proxy in the form [user:passwd@]proxy.server:port.

--timeout <sec>Set the socket timeout (default 15 seconds).

--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.

--cert <path> Path to alternate CA bundle.

1)打开mac终端,输入指令(项目所在位置/Users/kaka/Desktop/code/ssrpg-locust-slt ,即将本地电脑上的ssrpg-locust-slt项目拷贝到远程的code目录下)

scp /Users/dingyuanlin/Desktop/code/ssrpg-locust-slt [email protected] :/code/

2)进入服务器linux环境,可在/code/目录下查看到复制的文件

3)在linux环境下查看python环境是否ok

a)先查看python3,安装python3版本

b)查看是否安装pip ——pip -V可查看,若无 执行如下指令

curl https://bootstrap.pypa.io/get-pip.py | python3

yum install gcc python-devel

pip install -r requirements.txt

c)安装redis

yum install epel-release

yum repolist

yum install redis

d)启动redis服务

service redis start

e)python3 run.py

注意 :

1. 拷贝的命令是需要在客户端执行,即当前文件夹在哪个位置就需要从哪个系统控制台输入命令

2. mac系统下使用brew,而centos系统下需要使用yum命令

3. nohup redis-server >web6.log 2>&1 </dev/null&(nohup表示永久运行,&表示后台运行,该指令为redis服务后台运行)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7250197.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-03
下一篇 2023-04-03

发表评论

登录后才能评论

评论列表(0条)

保存