Import Numpy library in flutter using starflut - python-3.x

I want to run a python script in my flutter app. Thanks to starflut package which helped to do this. Now I want to run a python script that uses NumPy and OpenCV libraries. I want to import these libraries into my python script. I researched a lot about how can I achieve this I couldn't find a way. So I'm posting here so that whoever got the solution for this problem can suggest to me how to do this.

Related

Breusch-Pagan_test in Python 3

I am trying to run the Breusch-Pagan test in python 3 using the below code. It works perfectly in python 2.7, but when I run it in Anaconda with python 3.6 instead, I get the following the error: "module 'statsmodels.stats.api' has no attribute 'het_breuschpagan'".
I have looked at the statsmodel documentation at this link, https://www.statsmodels.org/devel/generated/statsmodels.stats.diagnostic.het_breuschpagan.html, and know that I am running the right code.
import statsmodels.stats.api as sms
breuschpagan_test = sms.het_breuschpagan(model_run.resid, model.model.exog)
Does anyone know a solution to this or a different way to call this statsmodel function in python 3?
Also, due to limitations at work, I cannot uninstall/re-install or update my statsmodel library at the moment either.
Thanks in advance!

SKLearn 0.20.2 - Import error with RandomizedPCA?

I'm trying to do the Udacity mini project and I've got the latest version of the SKLearn library installed (20.2).
When I run:
from sklearn.decomposition import RandomizedPCA
I get the error:
ImportError: cannot import name 'RandomizedPCA' from 'sklearn.decomposition' (/Users/kintesh/Documents/udacity_ml/python3/venv/lib/python3.7/site-packages/sklearn/decomposition/__init__.py)
I actually even upgraded the version using:
pip3 install -U scikit-learn
Which upgraded from 0.20.0 to 0.20.2, which also uninstalled and reinstalled... so I'm not sure why it can't initialise sklearn.decomposition.
Are there any solutions here that might not result in completely uninstalling python3 from my machine?! Would ideally like to avoid that.
Any help would be thoroughly appreciated!
Edit:
I'm doing some digging and trying to fix this, and it appears as though the __init__.py file in the decomposition library on the SKLearn GitHub doesn't reference RandomizedPCA... has it been removed or something?
Link to the GitHub page
As it turns out, RandomizePCA() was depreciated in an older version of SKLearn and is simply a parameter in PCA().
You can fix this by changing the import statement to:
from sklearn.decomposition import PCA as RandomizedPCA
... and then your classifier looks like this:
pca = RandomizedPCA(n_components=n_components, svd_solver='randomized', whiten=True).fit(X_train)
However, if you're here because you're doing the Udacity Machine Learning course on Eigenfaces.py, you'll notice that the PIL library is also deprecated.
Unfortunately I don't have a solution for that one, but here's the GitHub issue page, and here's a kind hearted soul that used a Jupyter Notebook to solve their mini-project back when these repositories worked.
I hope this helps, and gives enough information for the next person to get into Machine Learning. If I get some time I might take a crack at recoding eigenfaces.py for SKLearn 0.20.2, but for now I'm just going to crack on with the rest of this course.
In addition to what #Aaraeus said, the PIL library has been forked to Pillow.
You can fix the PIL import error using
pip3 install pillow

TinyTag import error python 3.3

I have been trying to import tinytag into python to be able to read mp3 tags but I keep receiving the same error. This is the code I am running
from tinytag import TinyTag
tag = TinyTag.get('/some/music.mp3)
print(tag.album)
and the error I recieve from this is
ImportError: No module named 'tinytag'
If anyone could give me any information on how to fix this would be greatly appreciated or can suggest another reader to use that is compatible with python 3.
Like you, I'm new to Python and I struggled with this but I worked it out eventually. I'm sure there is better way, but this worked (on windows, with my examples)
I installed a python module called easy_install (bundled with
setuptools). you can Google this. In the directory \Python26\Scripts you should see an exe file called easy_install if this has worked
Then I downloaded TinyTag to my pc eg
\downloads\tinytag-0.6.1.tar.gz
Then in note pad I wrote a small text file called myinstall.bat with
the contents
easy_install C:/downloads/tinytag-0.6.1.tar.gz
pause
then saved it into \Python26\Scripts and ran it (the pause keeps the
window open so you can see it worked)
Subsequently I started using some software called JetBrains to code with (it's commercial but there is a free edition) and that has an install tool built in which is even easier) I hope this helps

What is the easyest way to create a settings file in python

I am just making something to start up minecraft with , and I need a way to save some settings to a file , but I have no idea what I should use to do it . I googled my question already and what I got was information about pyYaml configparser and configobj I belive.And after looking at it I got confused because im not to scripting and python. What I would like is a recommendation or a tutorial on using those modules or the modules that you guys suggest .
I am using python 3.2
I would use configparser, and there are examples/tutorial at the end of the documentation: http://docs.python.org/library/configparser.html#examples

Python 3 relative path conversion issue

I am currently working with converting Pycrypto over to Python 3.X
Whilst I seem to have the cryptography side working the same cannot be said for the tests
provided with the module :(
I have used the tests under Python 2.64 and all works fine.
I then ran '2to3' over the tests to generate new files in 3.X format.
There are several references to the following:
from .common import make_block_tests
Whenever I run the tests I get:
ValueError: Attempted relative import in non-package
If someone would point me towards a way to fix this it would be much appreciated :)
Cheers
Grail
You are trying to run the test files directly, then you can't have relative imports. Change them to be absolute imports, and it will solve the problem.

Resources