distutils deprecation warning on ubuntu 22.04 - python

I am deploying openstack using devstack but while deploying I encountered the following error:
Error on exit /opt/stack/devstack/tools/worlddump.py:22:
DeprecationWarning: The distutils package is deprecated and slated for
removal in Python 3.12. Use setuptools or check PEP 632 for potential
alternatives from distutils import spawn World dumping... see
/opt/stack/logs/worlddump-2022-12-29-234955.txt for details
I haven't tried anything since I don't know where to start.

This warning started to appear from python 3.10. You could use and older version of python, if it works with your other packages. It says this package will be removed in the coming version 3.12. Your program will keep running with this warning, however u can remove it in following ways:
Option 1:
Replace the library with setuptools1
Option 2:
Replace with copytree 2
Option 3:
When nothing works, do this:
$ pip install shutup
Then at the top of the code
import shutup;
shutup.please()
And no warnings will appear anymore. :D :D :D
or you can filter the warnings:
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)

Related

How to detect whether a third-party python package is available on a fixed python version like python3.4

I am embedding python code in my cpp application to provide python-code-runner service. Recently I encountered a problem when I really need to downgrade my python version from 3.8.10 to 3.4.4, so that my application can fit on windows xp.
I used to provided some automatically-installed python 3rd-party packages for my customers to use. Now, as the downgrade of python version, I have to downgrade the 3rd-party packages' version to let my app function fine.
The problem is that I have no idea how to determine whether a 3rd-party package is suitable for python3.4. Is there a way I can test it?
I searched for pypi to get a version suitable for python3.4, but it turns out that this does not work well, as some 3rd-party-libs may rely on other packages with a semanticVersion mark >=.
Take astroid==1.3.8 for an example. I googled and found this version satisfies 3.4.4, so I installed it, and found syntax error when I use import astroid in my python script. The error indicates a syntax error in the lib logilab-common.
File "C:\Python34\lib\site-packages\astroid\__init__.py",line 54, in <module>
from astroid.nodes import *
...... // some traceback
......
File "C:\Python34\lib\site-packages\logilab\common\deprecated.py", line 105
self._proxied: Any = proxied
^
SyntaxError: invalid syntax
It turns out that the package astroid requires logilab-common>=0.63.0, and when I use pip install astroid==1.3.8, it installed the latest logilab-common, which is 1.9.7, and it used a type annotation, which caused this syntax error.
I managed to install logilab-common==0.63.0, and it worked fine when I use import astroid.
Does that mean I can use astroid all fine in python 3.4.4? I am not quite sure whether other functions or apis in this package will raise some syntax error or crash unexpectedly. Is there a way I can test it?
In the case, always installing the minium-satisfied-version of dependency-libs definitely works fine, but that's too much work for me. I want to find a way to test the utility of the libs and their dependency-libs.

CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team

I upgraded my system from python 2 to python 3, and now when I run my code:
from cryptography.hazmat.backends import default_backend
I am getting this error
/usr/local/lib/python3.6/site-packages/paramiko/transport.py:33:
CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python
core team. Therefore, support for it is deprecated in cryptography and will be
removed in a future release.
How to resolve it?
One of the solutions here suggests using
from cryptography.utils import CryptographyDeprecationWarning
That didn't work in my case, since importing the warning object caused the warning itself as well.
Although it's not an elegant solution (since "elegant" would be to upgrade Python), the following worked for me instead:
warnings.filterwarnings(action='ignore',message='Python 3.6 is no longer supported')
I ran into this issue today and did some digging. Since the os is not provided I think you could consider one of the options below:
Upgrade your python version. This might be the best option since python 3.6 reached its EOL.
You might be using SSH in your code. Consider installing an older version of paramiko.
You can suppress the warning with these lines of code before importing Paramiko:
import warnings
warnings.filterwarnings(action='ignore',module='.*paramiko.*')
or If you want to be more selective about suppressing JUST that particular deprecation warning:
import warnings
from cryptography.utils import CryptographyDeprecationWarning
warnings.filterwarnings("ignore", category=CryptographyDeprecationWarning)
source for option 3
Check if you installed it using pip when you needed to use conda.
on ubuntu
sudo apt-get upgrade docker-compose
docker-compose must be 2.X
after that you need to refer old command to new command so do this
alias docker-compose='docker compose'

"unresolved import" in Python - all other imports worked so far?

I am a bit lost. I've just recently started working with python and have been able to use other libraries, that I've imported without any issues.
Install via pip command
Restart Visual Studio Community 2019
I can use the library
Now I wanted to import the docx2pdf library. But using the same 3 steps is not working and I don't know what to do.
from docx2pdf import convert <-- gets the error "unresolved import"
Also:
after installing it via pip I get the following message in addition to the installation being a success:
WARNING: The script docx2pdf.exe is installed in 'C:\Users\user\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
I didn't get this message from other libraries.
I am using windows 10.
Thanks for the help!
In VS Code, when we use the global python environment to install the module, we can use the command "pip show docx2pdf" to check its storage location is: "\users\username\appdata\local\programs\python\python38\lib\ site-packages"
It is recommended that you reinstall the module "docx2pdf" or try to delete the previously installed "docx2pdf" folder and reinstall it.
Run:

Getting "no module named builtin" ImportError

I'm getting:
"ImportError: No module named builtins"
that has only started happening after I installed a later version of PsychoPy (an application that uses Python that is used for writing psychology experiments). I was not getting this problem with an older version
I tried doing "sudo pip install future" like someone else recommended for fixing a similar problem. However, when I do this I get an "invalid syntax" error, and don't know of any other way around the problem. I would greatly appreciate any help on this.
Edit
Could it be you enter the command into a Python prompt? You are supposed to enter that command on the command line of your operating system shell. Which means not inside Python.
Original Answer
Like Deesha already mentioned in their comment, you must install the future package into the Python environment you wish to run PsychoPy in, e.g. via pip:
pip install future
or via conda:
conda install future
This is because newer versions of PsychoPy support both Python 2.7 and 3. The future package is used to ensure the code runs on both platforms.

Win7/Python3.3: PyLint failed to load its plugins

Good evening! I have installed pylint on python 3.3 and got following problem: at initialization step pylint fails to load plugin modules (from package pylint.checkers). Thanks to debuging I found that problem is in the comand
module = __import__(basename, globals(), globals(), None)
which is executed from __init__.py of the checkers package. basename is correct name of module (file) inside this package but without extension (I have checked this). However ImportError exception is raised. I culdn't step into __import__ function so I don't know what is exact reason of the exception. Is there any way to find out if it is bug of new version of python, incompatibility of pylint and new version of python or my fault (may be in configuring of python or installing of pylint)? My OS is Windows 7.
P.S. Sorry for my weak English. It isn't my native language.
As of 0.26, Python 3.3 is not supported by Pylint. Logilab mainly works with Python 2.x and so help with the most recent 3.x versions is deeply appreciated.
You should approach the team on the python-projects#lists.logilab.org mailing list to discuss this.

Categories