ARTICLE AD BOX
I'm trying to get a container running Python to connect to my Neo4j container in Docker.
I'm following the steps in the Neo4j GraphAcademy Python Installation tutorial (https://neo4j.com/docs/python-manual/current/install/) and Getting Started with Docker tutorial (https://neo4j.com/docs/operations-manual/current/docker/introduction/). In Windows 10 on the Docker Desktop, I'm getting an error when starting my container in Docker.
I started by uninstalling/deleting all previous python and neo4j versions. As well as deleting any environment variables associated with them. I've downloaded the latest versions of Python and Neo4j. I've installed the Python driver and installed the Neo4j image for Docker.
The Neo4j image starts with no problem in Docker. The Neo4j browser opens and logs me in (using the default credentials per the tutorial). The Docker starter image runs without issue as ewll. I've created very rudimentary Dockerfile and app.py files.
I put 'print' commands in the app.py file, so that I can see that the container is using my app.py file.
Any guidance is greatly appreciated.
--- pip freeze ---
neo4j==6.1.0
pytz==2025.2
--- User environment variables added to PATH ---
...\Python314\Scripts\
...\Python314\Launcher\
...\Python314\
--- System environment variables - NEO4J_HOME ---
...\...\neo4j-community-2025.11.2-windows\
--- Dockerfile ---
# Start your image with a node base image
FROM python
# The /app directory should act as the main application directory
WORKDIR /app
# Copy the app package and package-lock.json file
COPY . /app
# Start the app using serve command
CMD [ "python", "app.py" ]
--- app.py ---
print("This is testing") print("11:30") from neo4j import GraphDatabase driver = GraphDatabase.driver( "neo4j://localhost:7687", # (1) auth=("neo4j", "##########") # (2) ) driver.verify_connectivity() records, summary, keys = driver.execute_query( # (1) "RETURN COUNT {()} AS count" ) # Get the first record first = records[0] # (2) # Print the count entry print(first["count"]) # (3)--- Error ---
This is testing 11:30 Traceback (most recent call last): File "/app/app.py", line 3, in <module> from neo4j import GraphDatabase ModuleNotFoundError: No module named 'neo4j'