Installing shotgun api errors

Hey all,

Just tried to install the shotgun api with:
pip install git+git://github.com/shotgunsoftware/python-api.git

But I got this error:

C:\Users\STEVE>pip install git+git://github.com/shotgunsoftware/python-api.git
Traceback (most recent call last):
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\STEVE\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe\__main__.py", line 7, in <module>
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\commands\__init__.py", line 104, in create_command
    module = importlib.import_module(module_path)
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\commands\install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand, with_cleanup
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\req_command.py", line 16, in <module>
    from pip._internal.index.package_finder import PackageFinder
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\index\package_finder.py", line 21, in <module>
    from pip._internal.index.collector import parse_links
  File "c:\users\steve\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\index\collector.py", line 9, in <module>
    import mimetypes
  File "P:\Studio\software\appLibrary\shotgunApi\python-api\shotgun_api3\lib\mimetypes.py", line 571
    print USAGE
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(USAGE)?

Any ideas on how to fix this ?

Thanks

Steve

2 Likes

Yeah, print is a function now and cannot be called without parentheses.
Seems like mimetypes needs to be updated. I thought the python sg api was fully compatible with Python 3.
One thing you could try is run the installation with Python 2.7 as default.

This could be considered a bug.

1 Like

Thanks mmoshev, that worked!

however when adding
import shotgun_api3

I still get the error:
ModuleNotFoundError: No module named 'shotgun_api3'

I’ve added the package to the path environment variables. Is there something else I have to do?

1 Like

Hi @steveprimary,

It looks like there’s something going wrong with your python path and mimetypes is being imported from a version of shotgun-api3 that’s in your path instead of using the standard module.

Can you test this by opening a python 3 shell and checking the output of the following code:

import mimetypes
print(mimetypes.__file__)

This should give you something like

c:\users\steve\appdata\local\programs\python\python38-32\lib\mimetypes.py

and not

P:\Studio\software\appLibrary\shotgunApi\python-api\shotgun_api3\lib\mimetypes.py
6 Likes

Thanks Ehsan, I fixed my python path and all works fine now
:slight_smile:

5 Likes

I hit the same issue today on our farm. What is needed to update the vendored mimetypes to a py3 compatible version?