Python import pyLDAvis module - DeprecationWarning - python

I try to visualize my topic modeling results with the pyLDAvis python module. But when i try to import:
import pyLDAvis
import pyLDAvis.sklearn
Then i get the following warnings:
...\site-packages\msgpack_numpy.py:77: DeprecationWarning: The binary mode of fromstring
is deprecated, as it behaves surprisingly on unicode inputs.
Use frombuffer instead dtype=np.dtype(descr)).reshape(obj[b'shape'])
A lot of these warnings results, always in the same file.. Does somebody know, how I could fix this? Thanks!

Related

Unable to suppress DeprecationWarning in Python

I'm using scikit-learn on a supercomputer. I'm using the presently installed versions of the packages I need, and it works just fine. I have a local copy of the code for development.
Due to some apparent discrepancy in the sklearn and numpy versions on the system, I get the following warnings:
python3.7/site-packages/sklearn/utils/__init__.py:4: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Sequence
python3.7/site-packages/sklearn/ensemble/weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release.
from numpy.core.umath_tests import inner1d
I don't need to see this warning or fix anything because I'm not developing anything on this system, I just need it to run. But if I use this code in production mode, I am going to get this warning in my error file millions of times and I won't be able to find any errors that actually matter.
In my python scripts I have:
import warnings
warnings.simplefilter(action='ignore', category=DeprecationWarning)
import numpy as np
from sklearn import ensemble
from sklearn import metrics
in my bash script I have:
jsrun -n $2 python3 -W ignore::DeprecationWarning myscript.py $args &
I've read a lot of the answers to similar questions but I don't see why I'm still getting this warning. How can I make it go away?

pylint import error in vscode even though python executer successfully imports it

I am using vscode for coding my python code. I use pandas, numpy and requests library in my code. If I run the code, It works fine. But in VScode editor, in the problems section, always Its says the message as
Unable to import 'numpy' (pylint import error)
Unable to import 'pandas' (pylint import error)
Unable to import 'requests' (pylint import error)
I searched in StackOverflow questions to find the answer to this problem, It says to install pandas using pip. I did that also. But still I am facing the same problem. How to fix this problem in vs code editor
This is not telling you that numpy or pandas is not installed. It is telling you that pylint can't verify your numpy and pandas calls. Most of numpy and pandas is written in C, not Python.
The pylint documentation says
Linting C extension modules is not supported out of the box,
especially since pylint has no way to get an AST object out of the
extension module.
So there is no problem with your code, even if VSCode says it is a problem. It is a technical limitation of pylint. If it worries you, disable pylint message E401 for these import statements. Put #pylint: disable=E401 on the same line as your import statement.

DeprecationWarning: Module scipy.linalg.blas.fblas is deprecated, use scipy.linalg.blas instead

I've just now installed theano on my machine but when i try to use it - i.e import theano
I get this 'DeprecationWarning':
/usr/lib/python2.7/dist-packages/scipy/lib/_util.py:35: DeprecationWarning: Module scipy.linalg.blas.fblas is deprecated, use scipy.linalg.blas instead
DeprecationWarning)
When I comment out the above line the error doesn't show. I've tried updating scipy, numpy, theano.. but nothing works.
Any ideas on what's causing this warning and how to get rid of it?
You could avoid a Deprecation Warning. If you don't want it to show up you could add the following to your code.
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)

Can't find module in python

I'm trying to do a linear regression using scipy.stats.linregress(). However when I run my script, i get the error message
AttributeError: 'module' object has no attribute 'stats'*
I'm using the Anaconda python 2.7 distribution which in its documentation says to have the module installed. Anaconda documentation
In the python interactive interpreter, I can import the scipy module, but can't find stats. When I look up its __version__ it says 0.14, which should have the stats module..
I really can't guess why the stats is unavailable..
This error:
AttributeError: 'module' object has no attribute 'stats'
Means what it says. There is no attribute named stats in the scipy module.
Not because no such thing exists on disk, but because no such thing has been imported—because you never even tried to import it.
scipy is a package. As the Python tutorial explains, importing a package doesn't import all of its submodules.
Some packages have a __init.py__ that automatically imports some or all packages.* But that would be a bad idea for scipy, because there are a ton of them, so it would take some time to import all of them, and usually you only need one or two in a given project.
So, you just need to do this:
import scipy.stats
* There are also some cases like os which fake being packages but aren't, so you can use os.path without importing it, or cases like pyobjc that create special placeholder objects for their modules that automatically import the real modules when first accessed.
I get the same error when I import scipy instead of scipy.stats. Have you tried
import scipy.stats
scipy.stats.linregress()

Python error while using MysqlDb - sets module is deprecated

I'm currently getting the warning every time I run a Python script that uses MySQLdb:
/var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
I'd rather not mess with their lib if possible. I'm on Ubuntu server. Anyone know an easy way to fix that warning message?
Thanks
UPDATE:
Fixed it based on the suggestions below and this link: https://bugzilla.redhat.com/show_bug.cgi?id=505611
import warnings
warnings.filterwarnings('ignore', '.*the sets module is deprecated.*',
DeprecationWarning, 'MySQLdb')
import MySQLdb
Do this before the mysql module is imported
import warnings
warnings.filterwarnings(action="ignore", message='the sets module is deprecated')
import sets
You can ignore the warning using the warnings module, or the -W argument to Python. Don't ignore all DeprecationWarnings, though, just the ones from MySQLdb :)
All it means is the sets module (more specifically the immutableset part) is deprecated, and you should use it's replacement, set. Set is inbuilt so no need to import.
If you need an immutable set, frozenset() should work.

Categories