How to install Python 3.5 on Raspbian Jessie

别说谁变了你拦得住时间么 提交于 2020-01-03 08:40:11

问题


I need to install Python 3.5+ on Rasbian (Debian for the Raspberry Pi). Currently only version 3.4 is supported. For the sources I want to compile I have to install:

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

But I think that apt-get will install more than these packages, for example libpython3-dev.

I already install python3 from https://www.python.org/downloads/ but I think, that is not complete.

Can you give me some suggestion which way is the best to get this?

A similar question was posted here Install Python 3.5 with pip on Debian 8 but this solution seems not to work on arm64.


Edit:

regarding to the comment of Padraic Cunningham: The first step I have done before. The second one results into this:

$ 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'

回答1:


Head over to the RaspberryPi stackexchange and follow these instructions. To summarize:

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



回答2:


The suggestion of @Padraic Cunningham to install libssl header files was helpful.

sudo apt-get install libssl-dev

But after this I further had to install GCC higher version 5 and CMake higher 3.5. The new Raspian Stretch comes with Python 3.5 and additionally with GCC 6.1 and CMake 3.5.

So the easiest way was to upgrade my system to Stretch (at the moment under test):

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

This is quiet easy and always up to date. At the end this is my prefered solution :)



来源:https://stackoverflow.com/questions/39089698/how-to-install-python-3-5-on-raspbian-jessie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!