Unable to import pandas_profiling module, because of 'escape' from jinja2.utils dependency - jinja2

from pandas_profiling import profile_report
=================================================
ImportError: cannot import name 'escape' from 'jinja2.utils' (/opt/conda/lib/python3.7/site-packages/jinja2/utils.py)

It seems that escape module was dropped from newer versions of jinja2. The newer versions of pandas-profiling use markupsafe to import escape module (from markupsafe import escape). However, your version seems to already use the old import (from jinja2.utils import escape). You have two options:
Try to install a newer version of pandas-profiling.
Or install an older version of jinja2.
The following environment seems to be working:
Jinja2 3.1.1
MarkupSafe 2.0.1
numpy 1.22.3
pandas 1.4.2
pandas-profiling 3.1.0
Check this post, or this github issue for more information.

Related

Python2: Installing json_util

I used to import json_util from bson:
from bson import json_util
Now I get:
ImportError: cannot import name json_util
How can I install json_util now?
Did you do?
pip install bson
which isntalls this 3rd party package which does not include all the goodies found in MongoDB's package
https://pypi.org/project/bson/
json_util (and a host of other utils) are provided in MongoDB Inc's pymongo package.
pip install pymongo
https://pypi.org/project/pymongo/
As noted on the pymongo pypi page
Do not install the “bson” package from pypi. PyMongo comes with its
own bson package; doing “easy_install bson” installs a third-party
package that is incompatible with PyMongo.
some distros package MongoDB's bson package
You might be on RHEL derivative since you're looking at py27. EPEL has a slightly out of date version you can install with
yum install python-bson
http://fedora-epel.mirrors.tds.net/fedora-epel/7/x86_64/Packages/p/python-bson-2.5.2-4.el7.x86_64.rpm
mainline ubuntu also packages it (and also separates the C module into the -ext package)
https://packages.ubuntu.com/bionic/python-bson
apt-get install python-bson python-bson-ext
As noted in this issue and explained in the detailed answer, the quick fix is to
pip uninstall bson
pip uninstall pymongo
pip install pymongo

Import module "ipython" in Jupyter notebook

Can somebody please help me loading the ipython module into jupyter notebooks?
ipython is a dependency for Jupyter, so it's already installed.
It looks like you're trying to import ipython widgets (ipywidgets) for use in Jupyter. To do this, in your shell (outside of Jupyter) install ipywidgets:
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
Then import widgets:
import ipywidgets as widgets
Read the docs to learn more about installing and using ipython widgets.
I believe that part of the problem is the capitalisation of the IPython package in your import statement:
try: import IPython.html.widgets
I don't know if that will get you everything you want, but that's probably the issue regarding your import.

'Cannot find module' when import in TypeScript

I have a small problem with importing nodejs modules.
For http module this syntax is working well:
import * as http from "http";
But when I try to do the same with 'mysql2' node.js module:
import * as database from "mysql2";
I gave me an error:
Cannot find module 'mysql2'
And refuse to compile that line.
I even tried syntax like this (don't know why):
import {database} from 'mysql2';
But there's no error only when I write like this:
let database = require('mysql2');
In tsconfig.json I've set:
"module": "commonjs",
"moduleResolution": "node",
And of course I've already installed the modules through npm in project folder:
npm install mysql2 --save
So my question is, why the import don't work and I have error in Visual Studio Code?
I think the import does not work because you are missing typescript definitions for mysql2. You have not posted your typings.json (or tsd.json) but I guess for nodejs you have imported definitions, but not for mysql2, therefore you can import 'http' using 'import from' syntax and with mysql2 you have to use plain javascript nodejs 'require' for importing it.
Install the typescript type definition for myql2 as follows:
npm install --save-dev types/mysql2#semver:version
where version is your choice.
For example:
npm i --save-dev types/mysql2#semver:^1.0.0

Error in importing MySQL connector in Python 3.5

I am getting ImportError: No module named 'mysql' while I do the following...
>>> import mysql.connector
MySQL is installed and am on Python 3.5. I can't figure out. The above command is running fine in Python 2.7.
Unfortunately there is no mysql-connector available for python3.5.
So, you can use pymysql module which is a replacement for mysql-connector package
pip install pymysql
import pymysql
Connection = pymysql.connect(host='hostname', user='username', password='password',
db='database',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor )
ExecuteQuery(Connection)
Connection.close()
For me (OS X 10.11.4, Python 3.5.1), the mysql-connector-package installed itself (by default) into Python 2.7 that was also on my system. I copied the mysql package directory from:
/Library/Python/2.7/site-packages/mysql to /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mysql. Everything works. According to http://dev.mysql.com/doc/connector-python/en/connector-python-versions.html the connector package supports Python 3.3+.
Your specific installation path for the module may be different, but you can easily check this from the REPL using the sys.path:
https://leemendelowitz.github.io/blog/how-does-python-find-packages.html
As we need to be connecting MySQl with Python, the Python command assumes that the connector is enabled. So we need to follow the steps below:
open MySQL Installer;
go to "Custom settings";
go to "Connectors";
choose the connector\Python and version based on the one you are using;
add it;
use import mysql.connector.
It should run, in my case it did!
From Can't run MySql Utilities:
MYSQL Utilities assumes that the MySQL Connector for Python has been installed. If you install it (http://dev.mysql.com/downloads/connector/python/), MySQL Utilities should run OK.
I think this link may help you to solve your problem.

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