windows server 2019 installation: ImportError: No module named pwd

Issue #367 resolved
Serhiy Pikho created an issue

I’ve been following this installation Guide https://kallithea.readthedocs.io/en/latest/installation_win.html

But I seem to have hit a roadblock - Running the command kallithea-cli config-create my.ini creates the following errors

(Env) C:\Kallithea\Bin>kallithea-cli
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Kallithea\Env\Scripts\kallithea-cli.exe\__main__.py", line 4, in <module>
  File "c:\kallithea\env\lib\site-packages\kallithea\bin\kallithea_cli.py", line 18, in <module>
    import kallithea.bin.kallithea_cli_db
  File "c:\kallithea\env\lib\site-packages\kallithea\bin\kallithea_cli_db.py", line 18, in <module>
    from kallithea.lib.db_manage import DbManage
  File "c:\kallithea\env\lib\site-packages\kallithea\lib\db_manage.py", line 41, in <module>
    from kallithea.model.base import init_model
  File "c:\kallithea\env\lib\site-packages\kallithea\model\base.py", line 31, in <module>
    from kallithea.lib.utils2 import obfuscate_url_pw
  File "c:\kallithea\env\lib\site-packages\kallithea\lib\utils2.py", line 35, in <module>
    import pwd
ImportError: No module named pwd

Looking up the pwd module shows that its a unix specific module and not supported on windows. https://docs.python.org/2/library/pwd.html

This infomration has left me a bit confused…

Comments (5)

  1. Serhiy Pikho reporter

    Looking at the offending file; Looks like there is no try except in the import of pwd

    from __future__ import print_function
    
    import binascii
    import datetime
    import os
    import pwd
    import re
    import time
    import urllib
    

    but there is a try except for its usage

    def get_clone_url(clone_uri_tmpl, prefix_url, repo_name, repo_id, username=None):
        parsed_url = urlobject.URLObject(prefix_url)
        prefix = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/')))
        try:
            system_user = pwd.getpwuid(os.getuid()).pw_name
        except Exception: # TODO: support all systems - especially Windows
            system_user = 'kallithea' # hardcoded default value ...
    

  2. Serhiy Pikho reporter

    http://www.mergely.com/yeDhnuv5/

    The following changes seem to have worked:

    from __future__ import print_function
    
    import binascii
    import datetime
    import os
    import re
    import time
    import urllib
    
    try:
        import pwd
    except ImportError:
        print("running windows installation cannot use pwd keyring manager")
    

  3. Serhiy Pikho reporter

    Thanks for the offer Mads Kiilerich. Unfortunatley I can’t test anything: The Org I work for is looking to quickly switch from Bitbucket before the sunsetting and are looking for reliablity and usablity first.

    The only reason why I’m running it on windows is that I’m doing a comparision between kallithea and HgLabs. If the recocomeded operating system is linux then I can easily switch over.

  4. Log in to comment