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.
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.
Related
I've been facing a problem for some time and I'm not finding a solution. At the company where I work, I'm trying to implement Python, but when I run the conventional command "Pip install pandas" in my vscode terminal, it gives an error because the company blocks the installation of external libraries, so it's as if I had to install these libraries on a PC without connection.
How should I follow this procedure?
I downloaded the .whl library from PyPi:
pandas-1.5.2-cp310-cp310-win_amd64.whl
ran pip install pandas-1.5.2-cp310-cp310-win_amd64.whl -f ./ --no-index --no-deps
Ok, the installation was successful. But this installation of pandas by cmd is not going to my system, because when trying to import pandas in my vscode it is not running, as if it had not been installed.
Would it be possible for me to download several libraries and leave them located in a folder where everyone in the company can use them? example using a function where I declare my path where all the libraries will be, and then I import them from there??
First confirm if you can run any python commands from VSCode. If the answer is yes, you can proceed to install your .whl file in python script folder.
Look for the Scripts folder
Add in your .whl file in this folder
Then open the folder, select the path, press Ctrl+D to display full path, type in cmd to open command prompt to this directory
Then just run your pip install here and you should be good to go
Remember the key is that your VSCode must be able to find Python.exe. If it can't from the start, you will need to add your python directory to PATH in environment variable
So, am working on making one of my python apps portable. (i.e.) Being capable of running off a pendrive without needing to install anything else on the user's computer.
For this I installed Python Version 3.9.8 onto my pendrive and wrote a bash script that calls
relativePathToPythonDirectoryInPendrive/python "relativePathToMyApp/myApp.py"
Unfortunately I have CairoSVG as one of my dependencies and when I installed the package via pip as follows,
relativePathToPythonDirectoryInPendrive/python -m pip install CairoSVG
At the end of installation, I get the following message :
WARNING: The script cairosvg.exe is installed in 'E:\Pendrive\PythonPortable\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
It seems that upon installing the CairoSVG package, a dependency cairosvg.exe is automatically added to the Scripts/ directory of python installed in my pendrive.
Since am calling python relatively and I have not intended on the user navigating to the Scripts/ folder to add to path in his/her computer, How to resolve the following Module Not Found error that arises on running the code :
ModuleNotFoundError: No module named 'cairo'
Thanks in advance !!!
I tried to install the keras_contrib package in a virtual machine which does not allow internet access. So I manually unzip the package, navigate to folder and using python setup.py install to install it. After that I can find the package using pip list, however when I import the package cannot be found. And I cannot find the package folder in the anaconda/lib/site-packages.
(link of the package: https://github.com/keras-team/keras-contrib)
These are the screenshots at the beginning and ending during installation.
Any suggestion? Thanks very much.
You should look at your $PYTHONPATH environment variables. If you are using Mac or Linux, write which python command on your terminal. Also, you can look at the link below for a setup that is similar to your problem
https://github.com/sparklingpandas/sparklingpandas/wiki/setup.py-Install-for-Anaconda-Python
I have built a module using "conda build packagename".
However, the built module ends up in "\Anaconda\conda-bld\work".
The module can only be imported (using "import packagename")if I cd into this directory, then run Python. I have tried placing the files in "\Anaconda\conda-bld\work" in "\Anaconda\Lib\site-packages", however I am not able to import the module from any directory; I must be in "\Anaconda\Lib\site-packages".
Is the only solution to put the .PYD file/ .SO file next to the executable Python file or is there a way to let Python know there is a new module installed?
Thank you for your help.
In the conda build script, you need to install the files, not just build them. For Python, this typically means running python setup.py install in the build.sh, and including python in your build dependencies so that the python will install into the build environment.
I have installed a python package slimit and I have cloned the source code from github.
I am doing changes to this package in my local folders which I want to test (often) but I don't want to do allways python setup.py install.
My folder structure is:
../develop/slimit/src/slimit (contains package files)
../develop/test/test.py
I'm using eclipse + pydev + python 2.7, on linux
Should I run eclipse with "sudo rights"?
Even better, is there a way to import the local development package into my testing script?
When you're working on a library you can use python setup.py develop instead of install. This will install the package into your local environment and keep it updated as you develop.
To be clear, if you use develop you don't have to run it again when you change your source files.