python多版本运行、python中shell命令运行、ImportError: cannot import name run

使用python和python3命令分别运行Python 2.x或Python 3.x, 如python多版本运行、python中shell命令运行、ImportError: cannot import name run_第1张图片
python中调用shell命令,使用

os.system("dexplorer -w")

shell中调用python命令行

python3 -c "import cv2;"

「Python」6种python中执行shell命令方法 - 子谦0618 - 博客园 https://www.cnblogs.com/wrxblog/p/9752412.html
(33条消息)python调用shell命令_python__V_-CSDN博客 https://blog.csdn.net/PARKED/article/details/90270970

ImportError: cannot import name run
错误发生在run只有在python3.5以上版本存在,需要用python3调用

切换python版本可以用工具pyenv和pythonbrew
pythonbrew安装及配置/macosx - 轻疯~ - 博客园 https://www.cnblogs.com/duqf/p/4155705.html
https://github.com/pyenv/pyenv
也可以用命令

source activate python27

永久将python指向python3.6方法
//查看python位置

which python

//先备份

sudo cp /usr/bin/python /usr/bin/python_cp

//删除

sudo rm /usr/bin/python

//默认设置成python3.6,创建链接

sudo ln -s /usr/bin/python3.6 /usr/bin/python
x = [i for i in range(10)]
print x

# This will give the output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# You can either use loops:
squares = []

for x in range(10):
    squares.append(x**2)
 
print squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

# Or you can use list comprehensions to get the same result:
squares = [x**2 for x in range(10)]

print squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

你可能感兴趣的:(Ubutun,Linux,嵌入式,python)