gremlinpython 3.8.0


pip install gremlinpython

  Latest version

Released: Nov 17, 2025

Project Links

Meta
Maintainer: Apache TinkerPop
Requires Python: >=3.10

Classifiers

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License

Natural Language
  • English

Programming Language
  • Python :: 3

Apache TinkerPop™ is a graph computing framework for both graph databases (OLTP) and graph analytic systems (OLAP). Gremlin is the graph traversal language of TinkerPop. It can be described as a functional, data-flow language that enables users to succinctly express complex traversals on (or queries of) their application’s property graph.

Gremlin-Python implements Gremlin within the Python language and can be used on any Python virtual machine including the popular CPython machine. Python’s syntax has the same constructs as Java including “dot notation” for function chaining (a.b.c), round bracket function arguments (a(b,c)), and support for global namespaces (a(b()) vs a(__.b())). As such, anyone familiar with Gremlin-Java will immediately be able to work with Gremlin-Python. Moreover, there are a few added constructs to Gremlin-Python that make traversals a bit more succinct.

Gremlin-Python is designed to connect to a “server” that is hosting a TinkerPop-enabled graph system. That “server” could be Gremlin Server or a remote Gremlin provider that exposes protocols by which Gremlin-Python can connect.

A typical connection to a server running on “localhost” that supports the Gremlin Server protocol using websockets from the Python shell looks like this:

>>> from gremlin_python.process.anonymous_traversal import traversal
>>> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
>>> g = traversal().with_remote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))

Once “g” has been created using a connection, it is then possible to start writing Gremlin traversals to query the remote graph:

>>> g.V().both()[1:3].to_list()
[v[2], v[4]]
>>> g.V().both()[1].to_list()
[v[2]]
>>> g.V().both().name.to_list()
[lop, vadas, josh, marko, marko, josh, peter, ripple, lop, marko, josh, lop]

Sample Traversals

The Gremlin language allows users to write highly expressive graph traversals and has a broad list of functions that cover a wide body of features. The Reference Documentation describes these functions and other aspects of the TinkerPop ecosystem including some specifics on Gremlin in Python itself. Most of the examples found in the documentation use Groovy language syntax in the Gremlin Console. For the most part, these examples should generally translate to Python with some modification. Given the strong correspondence between canonical Gremlin in Java and its variants like Python, there is a limited amount of Python-specific documentation and examples. This strong correspondence among variants ensures that the general Gremlin reference documentation is applicable to all variants and that users moving between development languages can easily adopt the Gremlin variant for that language.

Create Vertex

from gremlin_python.process.traversal import T
from gremlin_python.process.traversal import Cardinality

id = T.id
single = Cardinality.single

def create_vertex(self, vid, vlabel):
    # default database cardinality is used when Cardinality argument is not specified
    g.add_v(vlabel).property(id, vid). \
      property(single, 'name', 'Apache'). \
      property('lastname', 'Tinkerpop'). \
      next()

Find Vertices

def list_all(self, limit=500):
    g.V().limit(limit).element_map().to_list()

def find_vertex(self, vid):
    g.V(vid).element_map().next()

def list_by_label_name(self, vlabel, name):
    g.V().has(vlabel, 'name', name).element_map().to_list()

Update Vertex

from gremlin_python.process.traversal import Cardinality

single = Cardinality.single

def update_vertex(self, vid, name):
    g.V(vid).property(single, 'name', name).next()

NOTE that versions suffixed with “rc” are considered release candidates (i.e. pre-alpha, alpha, beta, etc.) and thus for early testing purposes only. These releases are not suitable for production.

4.0.0b1 Jan 23, 2025
3.8.0 Nov 17, 2025
3.7.5 Nov 17, 2025
3.7.5.dev1 Nov 17, 2025
3.7.4 Aug 08, 2025
3.7.3 Oct 29, 2024
3.7.2 Apr 15, 2024
3.7.1 Dec 04, 2023
3.7.0 Aug 04, 2023
3.6.8 Oct 29, 2024
3.6.7 Apr 15, 2024
3.6.6 Dec 04, 2023
3.6.5 Aug 04, 2023
3.6.4 May 17, 2023
3.6.3 May 05, 2023
3.6.3rc1 Feb 16, 2023
3.6.2 Jan 26, 2023
3.6.1 Jul 26, 2022
3.6.0 Apr 11, 2022
3.5.8 Dec 04, 2023
3.5.7 Aug 04, 2023
3.5.6 May 05, 2023
3.5.6rc1 Feb 16, 2023
3.5.5 Jan 26, 2023
3.5.4 Jul 26, 2022
3.5.3 Apr 11, 2022
3.5.2 Jan 14, 2022
3.5.1 Jul 26, 2021
3.5.0 May 10, 2021
3.4.13 Jan 14, 2022
3.4.12 Jul 26, 2021
3.4.11 May 10, 2021
3.4.10 Jan 22, 2021
3.4.9 Dec 11, 2020
3.4.8 Aug 07, 2020
3.4.7 Jun 05, 2020
3.4.6 Feb 24, 2020
3.4.5 Feb 07, 2020
3.4.4 Oct 18, 2019
3.4.3 Aug 09, 2019
3.4.2 Jun 03, 2019
3.4.1 Mar 22, 2019
3.4.0 Jan 08, 2019
3.4.0rc1 Jun 29, 2018
3.3.11 Jun 05, 2020
3.3.10 Feb 07, 2020
3.3.9 Oct 18, 2019
3.3.8 Aug 09, 2019
3.3.7 Jun 03, 2019
3.3.6 Mar 22, 2019
3.3.5 Jan 08, 2019
3.3.4 Oct 19, 2018
3.3.3 May 14, 2018
3.3.2 Apr 09, 2018
3.3.1 Dec 20, 2017
3.3.1rc1 Oct 31, 2017
3.3.0 Aug 25, 2017
3.2.11 Jan 08, 2019
3.2.10 Oct 19, 2018
3.2.9 May 14, 2018
3.2.8 Apr 09, 2018
3.2.7 Dec 20, 2017
3.2.7rc1 Oct 31, 2017
3.2.6 Aug 25, 2017
3.2.5 Jun 19, 2017
3.2.4 Feb 13, 2017
3.2.4.dev1486055820 Feb 02, 2017
3.2.4.dev1478023292 Nov 01, 2016
3.2.3 Oct 20, 2016
3.2.2rc1 Sep 11, 2016

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
nest_asyncio
aiohttp (<4.0.0,>=3.8.0)
aenum (<4.0.0,>=1.4.5)
isodate (<1.0.0,>=0.6.0)
async-timeout (<5.0.0,>=4.0.3)