Python版本冲突和符号链接

时间:2019-02-03 15:17:04

标签: python raspbian symlink

我想在Raspberry Pi OS上使用Python 3.7。我知道Raspbian已经安装了Python 2,无法将其卸载。我有Python 2,Python 3.5和Python 3.7。我遇到的问题是符号链接,我需要使用Pip安装一些库,该库应称为Pip3。完成Pip3 --version后,结果适用于Python3.5,而适用于Python 3.7。 pip 3.7不存在,所以我不确定Python 3.7的pip是什么或在哪里。

这就是我正在建立的link 要安装该软件,我可以使用setup.py或手动进行安装。这是setup.py使用的代码。

import os
import time

def replace_num(file,initial,new_num):  
    newline=""
    str_num=str(new_num)
    with open(file,"r") as f:
        for line in f.readlines():
            if(line.find(initial) == 0):
                line = (str_num+'\n')
            newline += line
    with open(file,"w") as f:
        f.writelines(newline)

for x in range(1,4):
    if os.system("sudo apt-get update") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get -y upgrade") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y i2c-tools") == 0:
        break

for x in range(1,4):
    if os.system("sudo pip3 install adafruit-pca9685") == 0:
        break

try:
    #replace_num("/boot/config.txt",'#dtparam=spi=on','dtparam=spi=on')
    replace_num("/boot/config.txt",'#dtparam=i2c_arm=on','dtparam=i2c_arm=on\nstart_x=1\n')
    #replace_num("/boot/config.txt",'#dtparam=i2s=on','dtparam=i2s=on')
except:
    print('try again')

for x in range(1,4):
    if os.system("sudo pip3 install pip setuptools wheel") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y swig") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y portaudio19-dev python3-all-dev python3-pyaudio") == 0:
        break

for x in range(1,4):
    if os.system("sudo pip3 install pyaudio") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y flac") == 0:
        break

for x in range(1,4):
    if os.system("sudo wget https://sourceforge.net/projects/cmusphinx/files/sphinxbase/5prealpha/sphinxbase-5prealpha.tar.gz/download -O sphinxbase.tar.gz") == 0:
        break

for x in range(1,4):
    if os.system("sudo wget https://sourceforge.net/projects/cmusphinx/files/pocketsphinx/5prealpha/pocketsphinx-5prealpha.tar.gz/download -O pocketsphinx.tar.gz") == 0:
        break

for x in range(1,4):
    if os.system("sudo tar -xzvf sphinxbase.tar.gz") == 0:
        break

for x in range(1,4):
    if os.system("sudo tar -xzvf pocketsphinx.tar.gz") == 0:
        break

try:
    os.system("cd sphinxbase-5prealpha/ && ./configure -enable-fixed && make && sudo make install")
    os.system("sudo pip3 install pocketsphinx")
except:
    pass

try:
    os.system("cd pocketsphinx-5prealpha/ && ./configure && make && sudo make install")
    os.system("sudo pip3 install SpeechRecognition")
except:
    pass

try:
    os.system("sudo pip3 install pocketsphinx")
except:
    pass

try:
    os.system("sudo pip3 install SpeechRecognition")
except:
    pass

for x in range(1,4):
    if os.system("sudo apt-get install -y bison libasound2-dev swig") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y python3.7 python3-dev python3-pip build-essentsudo apt-get install python3.7l libpulse-dev") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y libopencv-dev") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y python-opencv") == 0:
        break

for x in range(1,4):
    if os.system("sudo pip3 install imutils") == 0:
        break

for x in range(1,4):
    if os.system("sudo pip3 install opencv-python") == 0:
        break

for x in range(1,4):
    if os.system("sudo apt-get install -y libatlas-base-dev libjasper-dev libqtgui4 python3-pyqt5 libqt4-test") == 0:
        break

for x in range(1,4):
    if os.system("sudo pip3 install zmq pybase64") == 0:   ####
        break

for x in range(1,4):
    if os.system("sudo pip3 install rpi_ws281x") == 0:
        break

for x in range(1,4):
    if os.system("git clone https://github.com/oblique/create_ap") == 0:
        break

try:
    os.system("sudo cd //home/pi/adeept_picar-b/server/create_ap && sudo make install")
except:
    pass

for x in range(1,4):
    if os.system("sudo apt-get install -y util-linux procps hostapd iproute2 iw haveged dnsmasq") == 0:
        break

try:
    os.system('sudo mknod("//home/pi/.config/autostart/car.desktop")')
    with open("//home/pi/.config/autostart/car.desktop",'w') as file_to_write:
        file_to_write.write("[Desktop Entry]\n   Name=Car\n   Comment=Car\n   Exec=sudo python3 //home/pi/adeept_picar-b/server/server.py\n   Icon=false\n   Terminal=false\n   MutipleArgs=false\n   Type=Application\n   Catagories=Application;Development;\n   StartupNotify=true")
except:
    pass

os.system("sudo cp -f //home/pi/adeept_picar-b/server/set.txt /home/pi/set.txt")

try:
    os.system("sudo pip3 install pocketsphinx")
except:
    pass

print('restarting')

os.system("sudo reboot")

我尝试了两种安装方式,我相信原因是程序要使用Python3.7,而Python3.5是通过setup.py安装的。

因此,现在的操作系统已安装了Python3.5 Python3.7和Python2,我需要使用pip来安装软件包,而我找不到Python3.7 pip。命令pip3返回“ python3.5”,命令pip3.7不存在。如何从Python3.5到Pyton3.7删除pip3的符号链接 我花了很长时间在此安装上以重新格式化并重新开始,所以这不是一个选择。

0 个答案:

没有答案