Hi, how can we know that our python is properly installed or not
Open your terminal and type
When you hit enter it’ll tell you the version number as well as opening up the python interpreter by default.
If you mean within a project itself, please can you provide more details so we can help?
If the target user is a person, you can run
python --version to get the version number of the installed executable.
If the target user is a machine, you can use Bash Assert to check the output of the aforementioned call.
Note that an environment may have two Python executables:
python for Python 2.x and
python3 for Python 3.x.
What does “properly installed” mean? As others have mentioned, you can just try and run a python command and get some output, but I’m guessing you’re looking for more than that?
If you want to verify that libraries are installed, that things are in certain locations, etc, you’ll likely need to check each of those individually (probably a combination of listing directories, verifying checksums, and pip commands). You can leverage virtual environments to more efficiently manage libraries.
Alternatively, if you need a known python environment, this could be a good use case to leverage containerization (e.g. Docker).
My team use a “prepackaged” python archive to get around this problem, it also means we get to bake in any internal dependencies in one big archive. It’s super complicated and even I don’t know all the details of it’s workings well enough to explain, but this is a pretty well documented technique.
My biggest helper is simply to go “pip freeze”, and then check that the modules I expect, are at a consistent revision level. Getting a consistent Python environment across platforms starts in steps. You may want to look at all of the options before starting, one route is the egg archive : https://python101.pythonlibrary.org/chapter38_eggs.html .