Hello I'm trying to use Xfoil package using python. As the instructions say I installed the package and have written the following lines which are also shown in the documentation as a simple example. But, I always get error when running it in the second line xf=XFoil() and the error is
AttributeError: 'XFoil' object has no attribute '_lib'
Thanks for any suggestions
from xfoil import XFoil
xf = XFoil()
from xfoil.test import naca0012
xf.airfoil = naca0012
xf.Re = 1e6
xf.max_iter = 40
a, cl, cd, cm = xf.aseq(-20, 20, 0.5)
import matplotlib.pyplot as plt
plt.plot(a, cl)
plt.show()
I got the same error. I installed xfoil in my windows OS with python 3.7.13. The import from xfoil import XFoil worked fine however as you mentioned xf = XFoil() resulted in an attribute error. I tried the installation guidelines given in the Github page and that worked fine. For brevity I have copy pasted the guidelines below:
create a file named distutils.cfg in PYTHONPATH\Lib\distutils with the following contents:
[build]
compiler=mingw32
I hope that helps.
I have a problem with the plotly package. To be precise, I'm using auto-py-to-exe in order to have a file .exe which, if the users asks for it, plots a table using the plotly package. My code goes like this:
import pandas as pd
import plotly.graph_objects as go
import numpy
df= pd.read_excel (r'C:\Users\user\Desktop\Program\Data_Studio_Def.xls')
visualize_table= input('visualize table of patologies? (yes/no)')
if visualize_table== yes
fig = go.Figure(...)
fig.show()
Now, when I run the .exe made by auto-py-to-exe on the CMD (OS: Windows 10), I get some errors regarding modules like
Module plotly.validators.table not found
Once I add all such modules via hidden-import, I get the error:
FileNotFoundError No such file or directory : C\Users\user\output...
so it is searching for the plot in a folder rather than actually print it and I don't know how resolve this. Should I provide further informations?
P.S. I found out that the main problem is caused by the plotly package itself: I tried to build the exe via cx_Freeze rather than pyinstaller and the result was:
Module plotly.validators.table has no Attribute CellsValidators
Doing some searching I found out I'm not the only one with the same problem, the "HasNoAttribute", but uninstalling the package to then reinstall it again didn't do anything unfortunately.
My relevant file structure looks like this.
Project
-launcher.py
-lib
--bot
---__init__.py
launcher.py runs __init__.py in lib.bot like this:
#launcher.py
from lib.bot import bot
VERSION = "0.0.4"
bot.run(VERSION)
Here is where the issue is. I am trying to access the value of VERSION inside of __init__.py. I have tried using sys.argv but when I do that like this:
import sys
VERSION = sys.argv
print(VERSION)
it simply prints ['launcher.py'].
I have tried lots of other ways to access this value but, try as I might: I am unable.
Any thoughts?
# __init__.py
VERSION = '0.0.4'
# launcher.py
from lib.bot import VERSION # access VERSION like this
print(VERSION)
Hi I am using Anaconda with Python 3.7 and I have imported Pysal to my environment. Now I am trying to import a dataset and open it with pysal, to my surprise it appears that pysal does not have attribute open...
import pysal as ps
import libpysal as lps
lps.examples.explain('us_income')
csv_path = lps.examples.get_path('usjoin.csv')
f = ps.open(csv_path)
I am getting an error AttributeError: module 'pysal' has no attribute 'open'
How can I fix it?
The example dataset can be accessed using the modified script;
# Import packages
import pysal as ps
import libpysal as lps
# Load example data
lps.examples.explain('us_income')
csv_path = lps.examples.get_path('usjoin.csv')
# Note the difference here
f = ps.lib.io.open(csv_path)
These changes are a result of PySAL migrating to 2.0. This assumes you are using PySAL >=2.0. Please mark this answer as correct if this answers your question.
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()