I'm trying to run a python script through nodejs pythonshell but I keep getting a modulenotfound error when trying to import the libraries that I downloaded with pip. I installed pythonshell on my computer with npm, so I know that's not the problem.
1 Answer
When you install packages you will install them to a directory named site-packages
In your main directory this can be found from:
your-directory/lib/Python3.6/site-packages
If you copy and paste the files you'd like to run into this folder, and change the script path accordingly, the file will find all imported modules.
This is because the python shell was looking in the current directory for your packages and not finding them.
4 Comments
Avi Komarlingam
I'm trying to make an application with multiple scripts and sub directories that will eventually get turned into an exe file, so I'm not sure how feasible this is.
Helix
Just try packaging it and see how it runs.
Avi Komarlingam
I tried placing my project folder inside the site-packages folder and I got the same error
Gimantha23
It worked! Now I am not getting the modulenotfound error, but another error later in code @Helix