尝试安装模块时,即使已经安装了3.7,pip仍会安装python3.5

时间:2019-06-16 14:09:33

标签: python python-3.x pip

尝试为python3.7安装软件包时,使用pip install x会导致它安装python 3.5并在那里安装软件包。

这是针对运行最新版本的dietpi的Raspberry Pi Zero。我尝试使用不同的方法多次重新安装Pip,并且都产生了相同的结果。

用于安装python3.7pip的代码:

sudo apt-get update -y
sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev -y
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xf Python-3.7.0.tar.xz
cd Python-3.7.0
./configure
make -j 4
sudo make altinstall
cd ..
sudo rm -r Python-3.7.0
rm Python-3.7.0.tar.xz
sudo apt-get --purge remove build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev -y
sudo apt-get autoremove -y
sudo apt-get clean
sudo apt install python3-pip

#The code to install the module
pip3 install pillow

我希望Pip将模块安装到python3.7

1 个答案:

答案 0 :(得分:2)

自从您运行make altinstall(而不是make install)以来,现有的Python 3.5安装仍然是主要安装。也就是说,python3pip3仍指Python 3.5的解释器和包管理器,而python3.7pip3.7指Python 3.7。请参阅:CPython源存储库的自述文件中的"Installing multiple versions"。这是常见的做法,因为替换Python解释器可能会破坏依赖于它(或与之一起安装的库)的系统工具。