AWS Lambda issue with PostgreSQL - No module named 'psycopg2' - Uploading package from Windows - postgresql

I'm trying to create a layer and use it in Lambda function for PostgreSQL but getting the issue:
"errorMessage": "Unable to import module 'lambda_function': No module named 'psycopg2'",
"errorType": "Runtime.ImportModuleError"
I've tried uploading the Psycopg2 package from https://github.com/jkehler/awslambda-psycopg2 but still no progress. I've tried every version from 3.6 to 3.9. I'm using Windows OS.
What is the simplest way or the best solution for it?

Related

AWS Lambda Importing psycopg2 - Unable to import module 'app': No module named 'psycopg2._psycopg

I am trying to use the psycopg2 library with AWS lambda in my Pycharm IDE on Windows 10.
I have tried all versions of Python listed in this repository and I still always get the following error:
{"errorMessage": "Unable to import module 'app': No module named 'psycopg2._psycopg'", "errorType": "Runtime.ImportModuleError", "stackTrace": []}
I have tried this solution where we install aws-psycopg2 but it did not work. As per this solution, I have ensured that my local Python runtime and the Lambda runtime are the same and I still get the error.
I have made sure that my Python version is 64 bit as per this answer
Hey incase it still didn't work, i faced the same issue here's what i did:
ran this command:
pip install --platform=manylinux1_x86_64 --only-binary=:all: psycopg2-binary --target psycopg-binary/python/lib/python3.8/site-packages
created a lambda layer with the above package (pyscopg-binary) and added it to the lambda function
make sure runtimes are correct ( at first i had the lamda layer runtime 3.9 and the function 3.9, then i switched both to 3.8 and it worked)
Im not absolutely sure aside from the runtimes which of the packages caused it to work (since i did multiple things in one step: added aws-psycopg2 to the requirements.txt in addition to changing runtime, hence im not sure if the aws-psycopg2 had anything to do with it working :), but i think that it has nothing to do with it, so it should work without it).
hope this helps.

Why can't I add a package (module) I created in Julia?

I am having trouble installing a module I created in Julia. I am running the Julia plugin under Visual Studio Code. If I run the file below with Ctrl+F5 I get a message
ERROR: LoadError: ArgumentError: Package Utils not found in current path:
- Run `import Pkg; Pkg.add("Utils")` to install the Utils package.
This is the file:
module demo
using Utils
greet() = print("Hello World!")
end # module
If I follow the advice on the error message I get another error message:
ERROR: LoadError: The following package names could not be resolved:
* Utils (not found in project, manifest or registry)
I also tried inserting this line:
import Pkg; Pkg.add(path="C:/Dropbox/Code/Julia/demo/src/Utils.jl")
and got this message (although the path definitely exists):
ERROR: LoadError: Path `C:/Dropbox/Code/Julia/demo/src/Utils.jl` does not exist.
The files demo.jl and Utils.jl are in C:\Dropbox\Code\Julia\demo\src\ and the demo project has been activated as can be seen in the REPL. The OS is Windows 10 Pro.
Any help will be greatly appreciated. Lots of time wasted trying to make this work.
Module and packages are not the same things. In short, packages are modules plus a set of metadata that make it easy for the package to be found and interact well with other packages. See here for a tutorial to write Julia packages:
https://syl1.gitbook.io/julia-language-a-concise-tutorial/language-core/11-developing-julia-packages
In your case, if you want to load a local module, just type include("fileWhereThereIsTheModule.jl") followed by a using Main.MyModule or using .MyModule. Note the dot... without it, Julia would indeed look for a package and to let it find your Demo or Util module you would have to either change an environmental variable or place your module file in certain predefined folders. Using include followed by the "absolute or relative position" of the module you don't have to do either.

The inability to install the module on Python

I have a problem. When writing the "pip install pyowm" command to the console, the module is installed, but the system doesn't see it. For example, Phyton, when executing the command "impor pyowm", gives an error, and when writing the command "pyowm" to the console, the error "" pyowm " is not an external or internal command".
All of the above apply to other modules as well.
P.S. I use VS Code and Python v.3.8.3
From https://github.com/csparpa/pyowm:
from pyowm import OWM
The package name (pyowm) and the module name (OWM) do not necessarily need to correspond.
You can't just use any tool just by name from the console.
You have to first enter python to the console and then try import pyowm again.
It should import pyowm. But later you may want to actually use pyowm. Then you use this import most of the time:
from pyowm.owm import OWM

PySpark on Linux with pycharm - first exception error

I am trying to run my first PySpark script on a Linux VM I configured. The error message I have is KeyError: SPARK_HOME when I run the following:
from os import environ
from pyspark import SparkContext
I momentarily made this error go away by running export SPARK_HOME=~/spark-2.4.3-bin-hadoop2.7. I then ran into a new error error=2, No such file or directory. Searching took me to this page:https://community.cloudera.com/t5/Community-Articles/Tutorial-Install-Configure-iPython-and-create-run-PySpark/ta-p/246400. I then ran export PYSPARK_PYTHON=~/python3*. This brings me back to experiencing the KeyError: SPARK_HOME error.
Honestly, I'm stumbling through this, because it's my first time configuring Spark, and using PySpark. I still don't quite understand the ins-and-outs of pycharm, as well.
I expect to be able to run the following basic sample script on this page: https://medium.com/parrot-prediction/integrating-apache-spark-2-0-with-pycharm-ce-522a6784886f with no issues.
there is a package called findspark here
or you may use below code to set path if not found in environment
import os
if 'SPARK_HOME' not in os.environ:
os.environ['SPARK_HOME'] = 'full_path_to_spark_root'
[code continues]

Import/Export Plugin - will not install on IP3.9

Maybe I am making a fundamental error, but I assume you have to install the Import / Export plugin on IP3.9 to make the zip file before you import it to the new ip4.1 site ?
The plugin will not install in IP3.9 there is an error "plugin.ini doesn't exist"
The Import / Export plugin is not in the IP3.x format
ip_plugins/group_name/plugin_name/files
so I do not see how it can be installed.
If I try exporting data from IP4.1 I get the following error message
Error:
Fatal error: Call to undefined method Ip\Page::getType() in /var/www/ip41/Plugin/ImportExport/ManagerExport.php on line 207
I am probably doing something stupid, but I cannot see what
Alan
For v3.x version you must download a 3.x branch of the plugin - https://github.com/impresspages-plugins/ImportExport/tree/3.x
For the error in v4.1 open an issue on GitHub - https://github.com/impresspages-plugins/ImportExport/issues
I hope it does make sense now.