python-github3 icon indicating copy to clipboard operation
python-github3 copied to clipboard

Unable to install via pip (python 3.4)

Open LizzyTrickster opened this issue 11 years ago • 5 comments

When trying to pip3 install pygithub3 I get the following

bot@theender:~/EnderBot3/bin$ ./pip3 install pygithub3
Downloading/unpacking pygithub3
  Downloading pygithub3-0.5.1.tar.gz
  Running setup.py (path:/home/znc/EnderBot3/build/pygithub3/setup.py) egg_info for package pygithub3
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/home/znc/EnderBot3/build/pygithub3/setup.py", line 7, in <module>
        import pygithub3
      File "/home/znc/EnderBot3/build/pygithub3/pygithub3/__init__.py", line 10, in <module>
        from github import Github
    ImportError: No module named 'github'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/home/znc/EnderBot3/build/pygithub3/setup.py", line 7, in <module>

    import pygithub3

  File "/home/znc/EnderBot3/build/pygithub3/pygithub3/__init__.py", line 10, in <module>

    from github import Github

ImportError: No module named 'github'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/znc/EnderBot3/build/pygithub3
Storing debug log for failure in /home/znc/.pip/pip.log

Is there perhaps another step for installing that the readme doesn't tell about?

LizzyTrickster avatar Dec 01 '14 16:12 LizzyTrickster

I got it working by running pip3 install pygithub first. I'm not sure if it depends directly on that library or if that one correctly specifies dependencies, but it does work.

jpverkamp avatar Sep 08 '15 23:09 jpverkamp

I found what's probably the root cause of the above errors and the reason why installing pygithub first seems to resolve it:

pygithub3 uses a relative import: from github import Github -- it wants its own local github.py, but relative imports are only supported in Python 2; in Python 3 all imports must be absolute, or else this module would've had to do from .github import Github to explicitly import the local module. By installing pygithub first, you actually mask the underlying problem. When the __init__.py wants to import the local ./github.py module, it instead actually imports the other module you installed (pygithub).

The API is different between the two modules. You might end up with an error like this:

Traceback (most recent call last):
  File "./gitchangelog.py", line 309, in <module>
    github.main(args)
  File "./gitchangelog.py", line 38, in main
    reset=args.init)
  File "./gitchangelog.py", line 111, in authenticate
    self.api = Github(user=user, token=token, repo=repo)
TypeError: __init__() got an unexpected keyword argument 'repo'

kirsle avatar Mar 10 '16 04:03 kirsle

Hmm, the install looks to be a suboptimal way to solve it then (although in limited cases such as what I was doing, it does work well enough).

jpverkamp avatar Mar 10 '16 23:03 jpverkamp

Issue still valid. Solved the same way: pip install pygithub as prerequisite

Simone

chemelli74 avatar Apr 26 '22 09:04 chemelli74

Note that if you're solving this issue by doing pip install pygithub, you may actually end up with a Frankenstein's monster of a Python module.

Just use pygithub rather than python-github3 until the issue is properly fixed in this module. Per my earlier comment, installing pygithub "fixes" the issue because python-github3 actually ends up importing pygithub's github.py module rather than its own github.py module... which causes the error to go away, but now you have this module using the other module in weird ways that will likely lead to further confusion.

kirsle avatar May 09 '22 19:05 kirsle