如何从源代码安装python 3.4.3和在Debian上安装pip

Joh*_*ith 1 python linux debian

我正在尝试使用Python 3.4.3和pip在Debian上设置服务器.

我从源代码安装python 3.4.3到/ opt目录(是正确的安装到?).我将/ bin导出到路径中

export PATH="$PATH:/opt/python3.4.3/bin"
Run Code Online (Sandbox Code Playgroud)

但是当我关闭ssh时,当我重新登录时它不起作用.

并且没有脚本文件夹...所以pip在哪里?

Joh*_*ith 12

更新(2015年7月22日):使用pyenv - 它是一个python版本和虚拟环境管理器.对于Debian,apt-get将获得旧版本,因此最好使用从源安装的pyenv.您必须下载Python依赖项才能实现此目的:https://github.com/yyuu/pyenv/wiki/Common-build-problems.


它似乎pip打包在python源代码中.

在Debian上从源代码安装Python 3.4.3:

$ apt-get update 
$
$ cd /
$ sudo apt-get install libssl-dev openssl
$
$ cd opt
$ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
$ tar xzf Python-3.4.3.tgz
$
$ cd Python-3.4.3
$ ./configure
$ make
$ sudo make install
Run Code Online (Sandbox Code Playgroud)

使用:

$ python3
$ pip3
Run Code Online (Sandbox Code Playgroud)


bba*_*stu 5

将导出PATH变量的行添加到.profile中,重新登录后它将起作用.

你可以通过执行来做到这一点

echo 'export PATH="$PATH:/opt/python3.4.3/bin"' >> ~/.profile
Run Code Online (Sandbox Code Playgroud)

PATH您可以通过转到源目录的根目录并运行,只需将python安装到系统目录(放置得更好)中,而不是更改变量.

./configure
make
sudo make install
Run Code Online (Sandbox Code Playgroud)

如果pip在python源代码中分发,那么它也将被安装.通过执行检查是否已安装pip

pip --version
Run Code Online (Sandbox Code Playgroud)

如果不是,你也必须手动安装pip.

https://pip.pypa.io/en/latest/installing.html解释了这是如何完成的.只需下载脚本get-pip.py并像这样运行它

sudo python get-pip.py
Run Code Online (Sandbox Code Playgroud)