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

45 篇文章 3 订阅
38 篇文章 5 订阅

使用python和python3命令分别运行Python 2.x或Python 3.x, 如在这里插入图片描述
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]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值