命令行应用程序需要python3,但Ubuntu 16默认为python 2.7

时间:2018-01-18 21:48:41

标签: python-3.x python-2.7 command-line ubuntu-16.04 default

在终端命令行中公开google api服务的命令行应用程序shoogle(https://github.com/tokland/shoogle)需要python3,但ubuntu 16默认python是2.7。

我已尝试别名并在python3 shell中从subprocess调用shoogle应用程序,但(当然)os仍提供默认值。我一直不愿意对.bashrc或PYTHONPATH进行系统范围的更改,例如正如许多其他资源所期望的那样2.7。但我目前正在虚拟机上使用它,所以如果它确实破坏我可以恢复。这似乎是唯一的选择,但在生产环境中是不切实际的。

我发现网上有很少的帮助(作者建议SO等提供支持)所以如果有任何人有任何使用shoogle的经验或建议获得所需的python版本我会很高兴听到。

从python3解释器运行shoogle找到2.7文件:

3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609]
Python Type "help", "copyright", "credits" or "license" for more information.

from subprocess import call

call (['shoogle', 'show'])

Traceback (most recent call last):

File "/usr/local/bin/shoogle", line 11, in <module>
import shoogle

File "/usr/local/lib/python2.7/dist-packages/shoogle/__init__.py", line 5, 
in <module> from .shoogle import *

File "/usr/local/lib/python2.7/dist-packages/shoogle/shoogle.py", line 14, in <module>
from . import commands

 File "/usr/local/lib/python2.7/dist-packages/shoogle/commands/__init__.py", line 2, in <module>
from . import execute 

1 个答案:

答案 0 :(得分:0)

使用@Surest Texans建议我卸载了shoogle应用并使用pip3 install重新安装。现在,当从命令行调用时,应用程序按预期工作。

相关问题