Failing to import SQLAlchemy and Pymysql into AWS Glue Python Shell script - sqlalchemy

I have a Python script which imported 3 libraries:
import pymysql
import pandas as pd
from sqlalchemy import create_engine
I'm planning to run Python Shell on AWS Glue. Following this and this doc pages, I created a setup.py:
from setuptools import setup
setup(name="pylibmodule",
version="0.1",
packages=[],
install_requires=['sqlalchemy==1.3.9','pandas==0.25.3','pymysql==0.9.3']
)
I ran python setup.py bdist_wheel, put the resulting pylibmodule-0.1-py3-none-any.whl file into an S3 bucket, and then specified the bucket location in the Glue Job setting. When I ran the job script, it produced an error.
After an investigation, I found that I have sucessfully imported the pandas module, but failed to import sqlalchemy and pymysql.
ModuleNotFoundError: No module named 'sqlalchemy'
ModuleNotFoundError: No module named 'pymysql'
What am I doing wrong?

I ran the job again this morning without changing anything in the setting and the script. It suddenly works. I think the error I received last night was due to some cache residue on Glue's end.

Related

Unable to import BERT model with all packages

I am trying to learn NLP using BERT. While trying to import bert model and tokenizer in colab. I am facing the below error.
ImportError: cannot import name '_LazyModule' from 'transformers.file_utils' (/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py)
Here is my code
!pip install transformers==4.11.3
from transformers import BertModel, BertTokenizer
import torch
In order to fix the error.
I tried to upgrade both transformers and torch.
I have tried the solution from the below link:This
Still i am unable to go forward.
Please assist.
Based on these links 1, 2
This should help -
pip install 'lightning-flash[text]' --upgrade
Since the code provided by you is not the cause of the error as it runs on Colab when I tried it hence this might be the culprit in your environment

Installation of openzeppelin/contracts Library

I have created a node.js project, within which I have created a truffle directory and initialised its project. I have installed the openzeppelin (npm install #openzeppelin/contracts) library in this truffle project directory, but nothing appears to have been installed, although I did not received any error during the install process. The import statement in my project displays the error hereafter:
import "#openzeppelin/contracts/token/ERC721/ERC721Full.sol";
Source "#openzeppelin/contracts/token/ERC721/ERC721Full.sol" not found: File import callback not supported
It looks like they changed the name, and now the contract name is
ERC721.sol and not ERC721Full.sol, so try
import "#openzeppelin/contracts/token/ERC721/ERC721.sol";
Try this:
import "github.com/openzeppelin/contracts/token/ERC721/ERC721Full.sol"

Access to a MySQL database via Jupyter Notebook w/ Python3

I needed access a MySQL database via Jupyter Notebook, on which I run Python 3.6 (Anaconda install). It's a linear workflow, extracting data from the DB and manipulating it in Python/Pandas. No need for an ORM, a simple connector should do. However, the widely referenced MySQLdb package doesn't work with Python 3.x.
What are the alternatives?
The recommended installation modality for Jupyter on Ubuntu is Anaconda, so the appropriate package manager is conda. Installation via pip/pip3 or apt won't be accessible to the Notebook. conda makes it simple to get at least two good connectors:
pymysql works well and is easy to install:
sudo conda install pymysql
The 'official' connector:
sudo conda install mysql-connector-python
I tried pymysql first and it was fine but then switched to the second option due to the availability of extensive documentation.
If your objective is to import the data into a Pandas dataframe then use of the built-in pd.sql_read_table or pd.sql_read_query is convenient, as it labels the columns etc. It still requires installation of a connector, as discussed above.
An example with MySQL-connector-python, where you need to enter the database DETAILS:
import pandas as pd
import sqlalchemy
engine = sqlalchemy.create_engine('mysql+mysqlconnector://USER:PASSWORD#HOST/DB_NAME')
example_df = pd.read_sql_table("YOUR_TABLE_NAME", engine)

PyAutoGUI Python 3.5 Shell

I installed Pyautogui correctly and a I can import it from Python 3.5 but not from a script in IDLE Python 3.5.2
On the Shell the module pyautogui could not be found
I can't answer why an error is coming, but I may be able to solve your issue
Run this code on your Shell:
from subprocess import *
from sys import *
call([executable, "-m", "pip", "install", "pyautogui"])
Hope it helps :|

Use simplejson with Python 2.7 on GAE

Having trouble using simplejson with google app engine running Python 2.7.
Just switched from Python 2.5 on the Master/Slave datastore to Python 2.7 on the High Replication Datastore. This used to work:
from django.utils import simplejson
Now in order to use json, I can do this:
import json
However, I have a need to use simplejson. This works on the localhost debugger, but not on the server:
import simplejson
How can I use this library when running Python 2.7 on GAE?
Thanks!
I think json and simplejson are now compatible. If you've got code using simplejson, you could try
import json as simplejson