APOC plugin for Neo4j cannot be installed

Hello everyone,

I hope someone can help me to understand how to resolve this problem trying to access Neo4j from jupyter nootebook using langchain.graphs with Neo4jGraph: from langchain.graphs import Neo4jGraph

I am using a PC with Windows 11

I am using Docker to deploy Neo4j and followed the following steps, monitoring with Docker Desktop:

I have pulled image neo4j:

docker pull neo4j:5.13.0

I have run a container with the following string of commands:

docker run --name neo4j -e NEO4J_AUTH=user/password -p 7474:7474 -p 7687:7687 -v $PWD\data:/data -v $PWD\plugins:/plugins -e NEO4J_apoc_export_file_enabled=true -e NEO4J_apoc_import_file_enabled=true -e NEO4J_apoc_import_file_use__neo4j__config=true -e NEO4JLABS_PLUGINS='["apoc-extended"]' -e NEO4J_dbms_security_procedures_unrestricted=apoc.* -e NEO4J_dbms_security_procedures_allowlist=apoc.* neo4j:5.13.0

Seems everything is ok with the graphdb checking with Docker Desktop:

Authentication is ok

Bind mounts are ok in my file system

I have copied the file apoc-5.13.0-extended.jar in /plugins in my file system

Checking Files in Docker Desktop I can see /data and /plugins seems to be fine (I can see the .jar file inside plugins)

In Enviroments I can see this:

	"Env": [
		"NEO4JLABS_PLUGINS=[apoc]",
		"NEO4J_dbms_security_procedures_unrestricted=apoc.*",
		"NEO4J_dbms_security_procedures_allowlist=apoc.*",
		"NEO4J_AUTH=neo4j/pleaseletmein",
		"NEO4J_apoc_export_file_enabled=true",
		"NEO4J_apoc_import_file_enabled=true",
		"NEO4J_apoc_import_file_use__neo4j__config=true",
		"PATH=/var/lib/neo4j/bin:/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
		"JAVA_HOME=/opt/java/openjdk",
		"NEO4J_SHA256=c5b1834ae4493af9c623c7d4d68783de1f87d73adea34cd973d9daa3c2ea056c",
		"NEO4J_TARBALL=neo4j-community-5.13.0-unix.tar.gz",
		"NEO4J_EDITION=community",
		"NEO4J_HOME=/var/lib/neo4j"
	]

I have followed all the steps in:

and

and still got this error:

ValueError: Could not use APOC procedures. Please ensure the APOC plugin is installed in Neo4j and that 'apoc.meta.data()' is allowed in Neo4j configuration

Something additional is that when I run the container with:

NEO4JLABS_PLUGINS='["apoc-extended"]'
NEO4JLABS_PLUGINS='["apoc"]'

NEO4J_PLUGINS='["apoc-extended"]'
or
NEO4J_PLUGINS='["apoc"]'

I got these lines of error during execution:
parse error: Invalid numeric literal at line 1, column 2
parse error: Invalid numeric literal at line 1, column 2

when I remove NEO4J_PLUGINS environment configuration those errors don't appear.

But in both cases the main error trying to use Neo4J with langchain remains:

ValueError: Could not use APOC procedures. Please ensure the APOC plugin is installed in Neo4j and that 'apoc.meta.data()' is allowed in Neo4j configuration

I believe apoc plugin is not installed but I cannot find a way to do it effectively

Please help

I am ~90% sure that your problem is based on some escaping when it comes to define the NEO4J_PLUGINS env var.

For example my docker invocation contains ... -e NEO4J_PLUGINS=\[\"apoc-extended\"\].. (like in the APOC documentation you linked above).
If this works, the entry point of the docker image will fetch apoc-extended and install it. No need to manually download the library.

Hi Gerrit,
Thanks for replying! Merry holydays!

I have also tried -e NEO4J_PLUGINS=


["apoc-extended"] or -e NEO4J_PLUGINS=["apoc"] and the result is the same.

Every time I added any of those lines the log shows:

parse error: Invalid numeric literal at line 1, column 2
parse error: Invalid numeric literal at line 1, column 2

And the error :

ValueError: Could not use APOC procedures. Please ensure the APOC plugin is installed in Neo4j and that 'apoc.meta.data()' is allowed in Neo4j configuration

Continues when I call Neo4jGraph with langchain.

I am baffled, any ideas I would appreciate your help!!

Hi Gerrit,
I wonder if you mind to share the full chain of commands you are using to run neo4j docker image, please

I am attaching as a .jpg image, the chain of commands I used last time and the environments in running docker image.

How should the ne04j_pluging environment be showed in "Env"?

regards
Mario

Hi Gerrit,

Thanks I took your note and worked a little bit with the possible combination of using or not escaping characters inside the chain of commands and finally plugin was installed. Plugin apoc-extended installed but the options -e NEO4J_dbms_security_procedures_unrestricted=apoc.* -e NEO4J_dbms_security_procedures_allowlist=apoc.* appeared not to be working with it, but plugin apoc worked completely.

This is the result:

PS E:\DockerRps\neo4j> docker run --name neo4j-apoc -e NEO4J_AUTH=neo4j/pleaseletmein -p 7474:7474 -p 7687:7687 -e NEO4J_apoc_export_file_enabled=true -e NEO4J_apoc_import_file_enabled=true -e NEO4J_apoc_import_file_use__neo4j__config=true -e NEO4J_PLUGINS='["apoc"]' -e NEO4J_dbms_security_procedures_unrestricted=apoc.* -e NEO4J_dbms_security_procedures_allowlist=apoc.* neo4j:5.13.0

Installing Plugin 'apoc' from /var/lib/neo4j/labs/apoc-*-core.jar to /var/lib/neo4j/plugins/apoc.jar
Applying default values for plugin apoc to neo4j.conf
Changed password for user 'neo4j'. IMPORTANT: this change will only take effect if performed before the database is started for the first time.
2023-12-26 18:00:33.918+0000 INFO Logging config in use: File '/var/lib/neo4j/conf/user-logs.xml'
2023-12-26 18:00:33.936+0000 INFO Starting...
2023-12-26 18:00:34.626+0000 INFO This instance is ServerId{38ebf6ce} (38ebf6ce-0e46-4502-a5d2-da91d0800ab9)
2023-12-26 18:00:35.396+0000 INFO ======== Neo4j 5.13.0 ========
2023-12-26 18:00:39.801+0000 INFO Bolt enabled on 0.0.0.0:7687.
2023-12-26 18:00:40.316+0000 INFO HTTP enabled on 0.0.0.0:7474.
2023-12-26 18:00:40.317+0000 INFO Remote interface available at http://localhost:7474/
2023-12-26 18:00:40.319+0000 INFO id: 066E628C9AD028D243C6B002809E4D07D5B7D7BB9C31088D3875CCBB58D2CE79
2023-12-26 18:00:40.320+0000 INFO name: system
2023-12-26 18:00:40.321+0000 INFO creationDate: 2023-12-26T18:00:36.079Z
2023-12-26 18:00:40.321+0000 INFO Started.

here is a solution:

  1. copy this file 'apoc-5.14.0-core.jar' from /var/lib/neo4j/labs/ to /var/lib/neo4j/plugins
  2. update this file /var/lib/neo4j/conf/neo4j.conf
    dbms.security.procedures.unrestricted=apoc.*
    dbms.security.procedures.allowlist=apoc.*