Install python module inside of Django project - python

I would like to install a python module inside a Django project. That way i can modify the module to my needs. So when i upload the code to the server, it has the same code as locally. Unlike when i install the module via requirements.txt
For example: i want to customize the ShopifyApi module. So i download the source code to my project. But where do i have to put the module so that is behaves like a normal module?
Because now when i try to import the module with "import shopify" (which works when the module is installed with Pip) Django gives me the error:
ModuleNotFoundError: No module named 'shopify'
I have put the ShopifyApi modul code inside a custom shopify Django app.

Related

Odoo cannot import Python module

I have created the custom module in Odoo12. The module has a the function with #api.model to send the data to another local server.
I cannot import pydantic to the code or any other modules from python. I cannot even import numpy
I have tried to install the library in virtual reality, using the installed python on the computer, and add pydantic to the requirements.txt file.

Install a python module in the same directory as the main handler

Hello I want to install a module named python-ldap locally in the same directory as my main so that it could be zipped and uploaded as a standalone function. The reason is AWS Lambda doesn't support installing this module (but i have installed it successfully on AmazonLinux). So I'm hoping i can install the module in an AmazonLinux instance and zip it so it runs on any instance. If its possible that is.
For example purposes i have a folder deploy-ldap with a single lambda_function.py inside.
The lambda_function.py simply imports the module like so:
import ldap
def main():
print("Success")
What I tried so far:
There are some resources on this suggesting to copy a single .so file but it didn't work for me and resulted in an error where another .so.2 file is being requested
Furthermore i tried installing the module with pip install python-ldap -t . but this also resulted in an error: "Unable to import module 'lambda_function': No module named '_ldap'"
All input appreciated, thank you. ^^
The import python-ldap is incorrect because module names in Python shouldn't contain dashes. The correct import as in the examples should be:
import ldap
Then to make it available in the environment of your AWS Lambda function, you should follow the same steps as documented in Deployment package with dependencies which consists of the following steps:
Prepare the file containing the code
Perform pip install python-ldap
Deploy the code along with the installation to AWS Lambda

Module importing works in python console (pycharm) but not works on terminal

Hi i'm recently working on a module in python (package named pykiwoom)
I installed a module in conda 32-bit environment pip install pykiwoom and tried to import this
from pykiwoom.kiwoom import Kiwoom
This works perfectly fine when I execute this in python console in pycharm
However, when I try this in terminal error occurs
ModuleNotFoundError: No module named 'pykiwoom.kiwoom'; 'pykiwoom' is not a package
internal structure of package pykiwoom looks like this
pykiwoom
init.py
kiwoom.py
parser.py
Can somebody tell me why this error occurs?
I think where you install your package is important in your case. You can check the packages installed using pip list in terminal, and check if you find it there.
This solution provides overview of how to setup your files as packages and modules.
Nevertheless, I think if you install your package in the terminal using pip, you could possibly access it.

Pip - No module named vimpdb

I'm trying to install the vimpdb lib but it's working, even though I successfully installed vimpdb using pip install I always get this error:
import vimpdb; vimpdb.set_trace();
ImportError: No module named vimpdb
I'm running the code locally but when I run the same code as a simple script (without using localhost) it imports correctly, it only throws an error when I start a server and begin to try using this plugin.
Any ideas?
Thansk!
App Engine won't import Python modules on your Python path. You need to actually include the module within the App Engine project.
For example, in the same directory as app.yaml, you could add a symbolic link similar to this:
vimpdb -> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vimpdb
Or you could copy the vimpdb directory to that location.

Add python modules to Azure

When I run a python script that I set up on WebJobs in Azure - I get the following error:
import MySQLdb
ImportError: No module named MySQLdb
job failed due to exit code 1
I found some articles that seem to suggest to install python modules to a directory created on the webapp. How/Where would I install those modules?
Have you tried this?
http://nicholasjackson.github.io/azure/python/python-packages-and-azure-webjobs/
(from the site):
Step 1.
If you are using OSX and the default Python 2.7 install your packages
installed with pip will be in /usr/local/lib/python2.7/site-packages,
create a folder called site-packages in the root of your python job
and copy any packages you need for your job into it.
Step 2
Next you need to modify your run.py or any other file which requires
access to the package files. At the top of the file add….
import sys
sys.path.append("site-packages")

Categories