Python 没有在安装目录中安装名为 "python" 的可执行文件
Python not installing executable named "python" in install directory
我正在处理 DigitalOcean 上的一个 droplet:
CentOS7 x64
我想安装 python v 3.5.3 并在输入 'python'
时安装 运行
我用这个页面作为参考:
https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4
我做了以下下载和编译 python:
sudo yum group install "development tools"
作为本地用户 joe:
cd ~
wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
tar zxfv Python-3.5.3.tgz
find ~/python -type d | xargs chmod 0755
cd Python-3.5.3
./configure --prefix=/usr/local
make
sudo make altinstall
/usr/local/bin 看起来像这样:
-rwxr-xr-x 1 root root 101 Mar 26 21:20 /usr/local/bin/2to3-3.5
-rwxr-xr-x 1 root root 242 Mar 26 21:20 /usr/local/bin/easy_install-3.5
-rwxr-xr-x 1 root root 99 Mar 26 21:20 /usr/local/bin/idle3.5
-rwxr-xr-x 1 root root 214 Mar 26 21:20 /usr/local/bin/pip3.5
-rwxr-xr-x 1 root root 84 Mar 26 21:20 /usr/local/bin/pydoc3.5
-rwxr-xr-x 2 root root 12309712 Mar 26 21:19 /usr/local/bin/python3.5
-rwxr-xr-x 2 root root 12309712 Mar 26 21:19 /usr/local/bin/python3.5m
-rwxr-xr-x 1 root root 3080 Mar 26 21:20 /usr/local/bin/python3.5m-config
-rwxr-xr-x 1 root root 236 Mar 26 21:20 /usr/local/bin/pyvenv-3.5
没有 'python' 可执行文件 'python3.5' 唯一的 'python' 可执行文件位于
/home/joe/Python-3.5.3
-rwxrwxr-x 1 bucket bucket 12309712 Mar 26 21:16 python
大小一样,应该是同一个文件。我是否应该在 /usr/local/bin 中创建一个名为 python 的符号 link 指向 python3.5?我认为这是一种 hack,但我看不出我做错了什么。
另外,我无法调用 pip。
我尝试安装它:
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py -O - | python3.5 - --user
--2017-03-26 21:47:19-- https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.0.175, 151.101.192.175, 151.101.64.175, ...
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.0.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1595408 (1.5M) [text/x-python]
Saving to: ‘STDOUT’
100%[=======================================================================================================>] 1,595,408 --.-K/s in 0.08s
2017-03-26 21:47:19 (19.6 MB/s) - written to stdout [1595408/1595408]
Requirement already up-to-date: pip in /usr/local/lib/python3.5/site-packages
[bucket ~]$ pip
-bash: pip: command not found
谢谢。
replace/override python
二进制文件(我认为是 Python 2.7)和 Python 3.5 二进制文件不是一个好主意。这反过来意味着系统上的所有内容现在都将使用您的新解释器 - 并且可能会中断。事实上,Debian 认为 "python" 将始终指代 Python 2.7.
更新您的程序以使用 python3.5
二进制的想法要好得多,也更安全。
或者使用虚拟环境
感谢 Penguin Brian 和 abccd 对 virtualenv 的建议。它允许我设置本地 'python' 可执行文件。我安装了它并设置了一个可用的 virtualenv。
sudo yum groupinstall "Development tools"
sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
cd /usr/local/src
sudo wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tar.xz --no-check-certificate
sudo tar xf Python-3.5.3.tar.xz
cd Python-3.5.3
sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
sudo make
sudo make altinstall
sudo pip3.5 install virtualenv
sudo pip3.5 install virtualenvwrapper
作为本地用户:
mkdir ~/Envs
将以下行添加到 .bashrc
export WORKON_HOME=$HOME/Envs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
source /usr/local/bin/virtualenvwrapper.sh
保存文件然后:
source ~/.bashrc
mkvirtualenv <yourname>
当您重新登录访问 virtualenv 时:
$workon <yourname>
(yourname)$ python --version
Python 3.5.3
我正在处理 DigitalOcean 上的一个 droplet:
CentOS7 x64
我想安装 python v 3.5.3 并在输入 'python'
时安装 运行我用这个页面作为参考:
https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4
我做了以下下载和编译 python:
sudo yum group install "development tools"
作为本地用户 joe:
cd ~
wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
tar zxfv Python-3.5.3.tgz
find ~/python -type d | xargs chmod 0755
cd Python-3.5.3
./configure --prefix=/usr/local
make
sudo make altinstall
/usr/local/bin 看起来像这样:
-rwxr-xr-x 1 root root 101 Mar 26 21:20 /usr/local/bin/2to3-3.5
-rwxr-xr-x 1 root root 242 Mar 26 21:20 /usr/local/bin/easy_install-3.5
-rwxr-xr-x 1 root root 99 Mar 26 21:20 /usr/local/bin/idle3.5
-rwxr-xr-x 1 root root 214 Mar 26 21:20 /usr/local/bin/pip3.5
-rwxr-xr-x 1 root root 84 Mar 26 21:20 /usr/local/bin/pydoc3.5
-rwxr-xr-x 2 root root 12309712 Mar 26 21:19 /usr/local/bin/python3.5
-rwxr-xr-x 2 root root 12309712 Mar 26 21:19 /usr/local/bin/python3.5m
-rwxr-xr-x 1 root root 3080 Mar 26 21:20 /usr/local/bin/python3.5m-config
-rwxr-xr-x 1 root root 236 Mar 26 21:20 /usr/local/bin/pyvenv-3.5
没有 'python' 可执行文件 'python3.5' 唯一的 'python' 可执行文件位于
/home/joe/Python-3.5.3
-rwxrwxr-x 1 bucket bucket 12309712 Mar 26 21:16 python
大小一样,应该是同一个文件。我是否应该在 /usr/local/bin 中创建一个名为 python 的符号 link 指向 python3.5?我认为这是一种 hack,但我看不出我做错了什么。
另外,我无法调用 pip。
我尝试安装它:
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py -O - | python3.5 - --user
--2017-03-26 21:47:19-- https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.0.175, 151.101.192.175, 151.101.64.175, ...
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.0.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1595408 (1.5M) [text/x-python]
Saving to: ‘STDOUT’
100%[=======================================================================================================>] 1,595,408 --.-K/s in 0.08s
2017-03-26 21:47:19 (19.6 MB/s) - written to stdout [1595408/1595408]
Requirement already up-to-date: pip in /usr/local/lib/python3.5/site-packages
[bucket ~]$ pip
-bash: pip: command not found
谢谢。
replace/override python
二进制文件(我认为是 Python 2.7)和 Python 3.5 二进制文件不是一个好主意。这反过来意味着系统上的所有内容现在都将使用您的新解释器 - 并且可能会中断。事实上,Debian 认为 "python" 将始终指代 Python 2.7.
更新您的程序以使用 python3.5
二进制的想法要好得多,也更安全。
或者使用虚拟环境
感谢 Penguin Brian 和 abccd 对 virtualenv 的建议。它允许我设置本地 'python' 可执行文件。我安装了它并设置了一个可用的 virtualenv。
sudo yum groupinstall "Development tools"
sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
cd /usr/local/src
sudo wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tar.xz --no-check-certificate
sudo tar xf Python-3.5.3.tar.xz
cd Python-3.5.3
sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
sudo make
sudo make altinstall
sudo pip3.5 install virtualenv
sudo pip3.5 install virtualenvwrapper
作为本地用户:
mkdir ~/Envs
将以下行添加到 .bashrc
export WORKON_HOME=$HOME/Envs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
source /usr/local/bin/virtualenvwrapper.sh
保存文件然后:
source ~/.bashrc
mkvirtualenv <yourname>
当您重新登录访问 virtualenv 时:
$workon <yourname>
(yourname)$ python --version
Python 3.5.3