用pip安装的Python3脚本不起作用

时间:2015-12-14 06:25:05

标签: python pip blogger gdata pkg-resources

我使用python" pip"安装了一个应用程序:

sudo pip install EasyBlogger

安装完成且没有错误:

Collecting EasyBlogger
  Using cached EasyBlogger-0.9.0.zip
Requirement already satisfied (use --upgrade to upgrade): pypandoc in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): google-api-python-client in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): python-gflags in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): httplib2 in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python3.5/site-packages (from pypandoc->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): oauth2client>=1.4.6 in /usr/lib/python3.5/site-packages (from google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): six>=1.6.1 in /usr/lib/python3.5/site-packages (from google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): uritemplate>=0.6 in /usr/lib/python3.5/site-packages (from google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /usr/lib/python3.5/site-packages (from oauth2client>=1.4.6->google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules>=0.0.5 in /usr/lib/python3.5/site-packages (from oauth2client>=1.4.6->google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): rsa>=3.1.4 in /usr/lib/python3.5/site-packages (from oauth2client>=1.4.6->google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): simplejson>=2.5.0 in /usr/lib/python3.5/site-packages (from uritemplate>=0.6->google-api-python-client->EasyBlogger)
Installing collected packages: EasyBlogger
  Running setup.py install for EasyBlogger
Successfully installed EasyBlogger-0.9.0

然而,当我尝试以下列方式运行scipt时:

sudo easyblogger --blogid 6852822618950333369 get

我只收到错误消息:

Traceback (most recent call last):
  File "/usr/bin/easyblogger", line 9, in <module>
    load_entry_point('EasyBlogger==0.9.0', 'console_scripts', 'easyblogger')()
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 568, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2720, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2380, in load
    return self.resolve()
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2386, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.5/site-packages/blogger/__init__.py", line 1, in <module>
    from blogger import EasyBlogger, main
ImportError: cannot import name 'EasyBlogger'

/ usr / bin / easyblogger的内容如下:

#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'EasyBlogger==0.9.0','console_scripts','easyblogger'
__requires__ = 'EasyBlogger==0.9.0'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('EasyBlogger==0.9.0', 'console_scripts', 'easyblogger')()
    )

错误来自9. line load_entry_point。我该怎么做才能使easyblogger脚本正常工作?无论如何,我使用的是Arch Linux。

1 个答案:

答案 0 :(得分:0)

我看到你正在使用Python 3.看起来easyblogger不兼容,即使它是使用pip3安装的。

要看到这一点,请通过添加句点来更正__init__.py,因为您要从当前文件夹导入(python 3中的新内容):

from .blogger import EasyBlogger, main

现在,如果您运行命令,则会得到以下内容:

  File "/usr/local/lib/python3.4/dist-packages/blogger/blogger.py", line 424
    print postId
               ^
SyntaxError: Missing parentheses in call to 'print'

现在您需要决定是否修复包裹!只是为了确保在Python 3中安装:

sudo apt-get -y install python3-setuptools
sudo easy_install3 pip
sudo pip3 install EasyBlogger