polvoazul / shutup Goto Github PK
View Code? Open in Web Editor NEWStop python warnings, no matter what!
License: Do What The F*ck You Want To Public License
Stop python warnings, no matter what!
License: Do What The F*ck You Want To Public License
Hi there,
I made my own Python package which is composed of two scripts and a standard Python package with several folders.
Here's the content of the setup.py
:
from setuptools import setup
with open(f"README.md") as f:
long_description = f.read()
setup(name="stag",
version="0.0.0",
description="A CLI that simplifies the usage of MCMC methods.",
scripts=["bin/stag", "bin/stag-fs"],
packages=["stag"],
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=["click"],
url="https://github.com/jpmvferreira/stag",
author="José Ferreira",
author_email="[email protected]",
license="MIT",
zip_safe=False
)
Every time I run one of the binaries, I always get the following message:
/home/undercover/.micromamba/envs/stag/bin/stag:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
__import__('pkg_resources').require('stag==0.0.0')
I can't for the sake of anything turn it off, which is really annoying, especially because I'm not using anything that is non standard here.
My CLI utility depends on a single package, click
, and then uses Python built-in sys
and os
packages, nothing else.
Trying to suppress warnings doesn't cut it as well.
What to do?
Do you happen to know what is causing this deprecation warning anyways, and how it can be solved (either by shutting it up or by actually fixing it)?
Python 3.9 installed in a virtual environment.
Torchvision 0.14.1
Warnings:
/home/user/.env/py39pytorch/lib/python3.9/site-packages/torchvision-0.14.1-py3.9-linux-x86_64.egg/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
warnings.warn(msg)
/home/user/.env/py39pytorch/lib/python3.9/site-packages/torchvision-0.14.1-py3.9-linux-x86_64.egg/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=None`.
warnings.warn(msg)
Head of file that emits these warnings
#!/usr/bin/env python3
import sys
import argparse
from pathlib import Path
import shutup ; shutup.please()
import numpy as np
import torch.cuda
from joblib import Parallel, delayed
from tqdm_joblib import tqdm_joblib
from scipy.spatial.distance import jensenshannon
# other imports of local modules
# other code
moving call to shutup.please()
to the end of imports does not help, the following code still produces warnings:
#!/usr/bin/env python3
import sys
import argparse
from pathlib import Path
import numpy as np
import torch.cuda
from joblib import Parallel, delayed
from tqdm_joblib import tqdm_joblib
from scipy.spatial.distance import jensenshannon
# other imports of local modules
import shutup ; shutup.please()
# other code
Hi Fred,
I wasn't able to see any licensing for this component. Could you let me know the license it's made available under?
I've put ‘import shutup’ 'shutup.please' in the first line but it's still warning.
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
F_table[t, item] = optimizer.gbest_F
Sometimes the annoying warnings come up in specific moments of the program's execution. After those moments maybe some warnings would actually be helpful.
It would be really useful to have a function in this library that would be able to undo all the shut-uping.
Sort of 'Python, I've changed, please come back to me' type thing ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.