Search code examples
pythonfirebasepippipenv

How to install "python-firebase" with "pipenv"


In short
How to install latest version of pip package python-firebase using pipenv when pipenv install python-firebase not working?


Full detail

To have firebase working with python code, as guided officially from firebase homepage here, I use python-firebase library as listed there.

Install it by running pipenv install python-firebase, my code resulted with below error.

Traceback (most recent call last):
  File "/home/namgivu/code/namgivu/l/gcp/gcp_firebase_start/_.py", line 56, in <module>
    from firebase import firebase
  File "/home/namgivu/code/namgivu/l/gcp/gcp_firebase_start/.venv/lib/python3.10/site-packages/firebase/__init__.py", line 3
    from .async import process_pool
          ^^^^^
SyntaxError: invalid syntax

The solution for that is to install the latest version of python-firebase, as discussed here, but thru the pip directly not pipenv

pip install git+https://github.com/ozgur/python-firebase

I tried that with pipenv inplaceof pip, but didn't work

pipenv install git+https://github.com/ozgur/python-firebase

So my question is what to put into Pipfile so that we can get firebase ready-to-serve in our python code by simple install command pipenv install ?


Solution

  • According to the doc here from pipenv

    pipenv install is fully compatible with pip install syntax

    So you could try

    pipenv install \
        git+https://github.com/ozgur/python-firebase@0d79d7609844569ea1cec4ac71cb9038e834c355#egg=python-firebase
    

    as the recommendation you have linked suggested. Notice #egg=python-firebase is appended since pipenv requires an #egg fragment for version controlled dependencies.

    To answer your question, the following is the Pipfile generated by pipenv, although you should rely on pipenv to generate this file for you.

    
    [[source]]
    url = "https://pypi.org/simple"
    verify_ssl = true
    name = "pypi"
    
    [packages]
    python-firebase = {ref = "0d79d7609844569ea1cec4ac71cb9038e834c355", git = "https://github.com/ozgur/python-firebase"}
    
    [dev-packages]
    
    [requires]
    python_version = "3.9"