Python tabula-py cannot import name wrapper - python-3.x

Here is my code:
from tabula import wrapper
df = wrapper.read_pdf('singapore.pdf')
But it gives following error:
ImportError: cannot import name 'wrapper'
I tried it on ubuntu and it works fine there but on Windows I am unable to use this code, as it always gives the above error. I installed tabula by using this command:
pip3 install tabula-py

Here is how I resolved it, you need to add java path to environment variables. More details can be found here:
https://tabula-py.readthedocs.io/en/latest/getting_started.html#get-tabula-py-working-windows-10

Related

ImportError: No module named flask using MAC VSCODE

ScreenGrab of error when trying to import db I created
You either need to install Flask from pip, or something similar, or Python is not able to find the location of Flask if it is, in fact, installed.
At your Python prompt, try this to see where it is looking for libraries:
>> import sys
>> print (sys.path)

ImportError: cannot import name 'cluster_resolver'

I get this error when trying to setup Unity3d ml-agents
ImportError: cannot import name 'cluster_resolver'
Following https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation.md tutorial
from tensorflow.contrib import cluster_resolver
Error happens when I try to run mlagents-learn --help
I am on MacOS with Python 3.6
Fixed by using Tensorflow 1.7.0 instead of 1.7.1 as in the tutorial.

Pandas-profiling error AttributeError: 'DataFrame' object has no attribute 'profile_report'

I wanted to use pandas-profiling to do some eda on a dataset but I'm getting an error : AttributeError: 'DataFrame' object has no attribute 'profile_report'
I have created a python script on spyder with the following code :
import pandas as pd
import pandas_profiling
data_abc = pd.read_csv('abc.csv')
profile = data_abc.profile_report(title='Pandas Profiling Report')
profile.to_file(output_file="abc_pandas_profiling.html")
AttributeError: 'DataFrame' object has no attribute 'profile_report'
The df.profile_report() entry point is available from v2.0.0. soln from here
Did you install pandas-profiling via pip or conda?
use : pip install -U pandas-profiling to solve this and restart your kernel
The issue is that the team hasn't updated the pip or conda installations yet (described here). If you installed using one of these, try this for the time being.
profile = pandas_profiling.ProfileReport(df)
print(profile)
This should work for those who want to use the latest version:
Run pip uninstall pandas_profiling from anaconda prompt (given you're using Spyder, I'd guess this would be your case) / or command prompt
Run pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip
If you're using something like a Jupyter Notebook/Jupyter Lab, be sure to restart your kernel and re-import your packages.
I hope this helps.
For the those using google colabs, the profiling library is outdated, hence use the command below and restart the runtime
! pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip
The only workaround I found was that the python script I made is getting executed from the command prompt and giving the correct output but the code is still giving an error in Spyder.
Some of the version of the pandas-profiling does not work for me and I installed 2.8.0 version and it work for me.
!pip install pandas-profiling==2.8.0
import numpy as np
import pandas as pd
import pandas_profiling as pp
df = pd.read_csv('/content/sample_data/california_housing_train.csv')
profile = df.profile_report(title = "Data Profiling Report")
profile.to_file("ProfileReportTest.html")
If none of the above worked, can you check by setting the encoding to unicode_escape in read_csv? It may be due to one of your columns
encoding = 'unicode_escape'
My solution
For me installation via pip was giving errors, therefore I installed it via conda from here.
Code Example
And here is the code example to use profile report:
import pandas as pd
from pandas_profiling import ProfileReport
data_abc = pd.read_csv('abc.csv')
profile = ProfileReport(data_abc, minimal=True)
profile.to_file("abc_pandas_profiling.html")
To read the html file I used the following code
df = pd.read_html("abc_pandas_profiling.html")
print(df[0])
Try in conda environment
!pip install --user pandas-profiling
import pandas_profiling
data.profile_report()

Import error, there is no module named numpy, but it says that it is installed?

So I trying to install and run from MSFT the cntk, you know, just for fun. Anyway, I keep getting this error which says:
import numpy as np
ModuleNotFoundError: No module named 'numpy'
Now I have looked around here a little and I found a post saying that I needed to install the latest version of NumPy, but when I go to do that, I get back this:
Requirement already satisfied: NumPy in c:\users\username\appdata\local\continuum\anaconda3\envs\cntk-py34\lib\site-packages
SO I really have no idea what is going on here.
Anyway, thanks in advance.
Is your IDE linked to Anaconda env? If you open up the Anaconda prompt and import numpy do you get the same error?
You probably have an environment outside of Anaconda which does not have numpy installed.
In my case, I was executing [filename].py from the Anaconda prompt as I would a batch file and was getting this error. I confirmed numpy was install by executing pip list.
Funning python and passing the script file name as an argument, eg python [filename].py, correctly imported the numpy module and executed the script without error.

Python 3: No module named zlib?

I am trying to run my Flask application with an Apache server using mod_wsgi, and it has been a bumpy road, to say the least.
It has been suggested that I should try to run my app's .wsgi file using Python to make sure it is working.
This is the contents of the file:
#!/usr/bin/python
activate_this = '/var/www/Giveaway/Giveaway/venv/bin/activate_this.py'
with open(activate_this) as f:
code = compile(f.read(), "somefile.py", 'exec')
exec(code)
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Giveaways/")
from Giveaways import application
application.secret_key = 'Add your secret key'
However, when I run it, I get this error:
ImportError: No module named 'zlib'
And no, I am not using some homebrewed version of Python - I installed Python 3 via apt-get.
Thanks for any help.
does the contents of somefile.py include the gzip package? in which case you may have to install gzip package via pip or similar

Resources