我需要在Rasbian上安装Python 3.5+(Debian for Raspberry Pi)。目前仅支持3.4版。对于我想要编译的源代码,我必须安装:
sudo apt-get install -y python3 python-empy python3-dev python3-empy python3-nose python3-pip python3-setuptools python3-vcstool pydocstyle pyflakes python3-coverage python3-mock python3-pep8
但我认为apt-get
将安装超过这些软件包,例如libpython3-dev
。
我已经从https://www.python.org/downloads/安装了python3
,但我认为,这还不完整。
你能给我一些建议吗?哪种方式最适合这个?
这里发布了一个类似的问题Install Python 3.5 with pip on Debian 8,但这个解决方案似乎不适用于arm64。
编辑:
关于Padraic Cunningham的评论:我以前做过的第一步。第二个结果是:
$ sudo python3.5 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 19177, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "/tmp/tmpoe3rjlw3/pip.zip/pip/__init__.py", line 16, in <module>
File "/tmp/tmpoe3rjlw3/pip.zip/pip/vcs/subversion.py", line 9, in <module>
File "/tmp/tmpoe3rjlw3/pip.zip/pip/index.py", line 30, in <module>
File "/tmp/tmpoe3rjlw3/pip.zip/pip/wheel.py", line 39, in <module>
File "/tmp/tmpoe3rjlw3/pip.zip/pip/_vendor/distlib/scripts.py", line 14, in <module>
File "/tmp/tmpoe3rjlw3/pip.zip/pip/_vendor/distlib/compat.py", line 66, in <module>
ImportError: cannot import name 'HTTPSHandler'
答案 0 :(得分:14)
转到 RaspberryPi stackexchange 并关注these instructions。总结一下:
sudo apt-get install build-essential libc6-dev
sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
sudo apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
sudo apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
cd $HOME
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -zxvf Python-3.7.0.tgz
cd Python-3.7.0
./configure # 3 min 13 s
# Let's use 4 threads
make -j4 # 8 min 29 s
sudo make install # ~ 4 min
cd ..
sudo rm -fr ./Python-3.7.0*
# upgrade:
sudo pip3 install -U pip
sudo pip3 install -U setuptools
答案 1 :(得分:8)
@Padraic Cunningham建议安装libssl
头文件很有帮助。
sudo apt-get install libssl-dev
但在此之后我还需要安装 GCC 更高版本5和 CMake 更高版本3.5。新的 Raspian Stretch 附带 Python 3.5 以及 GCC 6.1 和 CMake 3.5 。
所以最简单的方法是将我的系统升级到Stretch(目前正在测试中):
sudo echo 'deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi' > /etc/apt/sources.list.d/stretch.list
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove
这很安静,总是最新的。最后这是我的首选解决方案:)