12/13/2023 0 Comments List all python versions ubuntu![]() ![]() _compat_pickle | /usr/lib/python3.4/_compat_pickle.py _collections_abc | /usr/lib/python3.4/_collections_abc.py _bootlocale | /usr/lib/python3.4/_bootlocale.py _future_ | /usr/lib/python3.4/_future_.py _codecs_iso2022 | /usr/local/lib/python3.5/lib-dynload/_codecs_iso2022.cpython-35m-x86_64-linux-gnu.soįor the CPython3.4 (truncated) $ python3.4 python_modules_info.py _codecs_hk | /usr/local/lib/python3.5/lib-dynload/_codecs_hk.cpython-35m-x86_64-linux-gnu.so _bisect | /usr/local/lib/python3.5/lib-dynload/_bisect.cpython-35m-x86_64-linux-gnu.so _sitebuiltins | /usr/local/lib/python3.5/_sitebuiltins.py _pyio | /usr/local/lib/python3.5/_pyio.py _pydecimal | /usr/local/lib/python3.5/_pydecimal.py _osx_support | /usr/local/lib/python3.5/_osx_support.py _markupbase | /usr/local/lib/python3.5/_markupbase.py _dummy_thread | /usr/local/lib/python3.5/_dummy_thread.py _compression | /usr/local/lib/python3.5/_compression.py _compat_pickle | /usr/local/lib/python3.5/_compat_pickle.py ![]() _collections_abc | /usr/local/lib/python3.5/_collections_abc.py _bootlocale | /usr/local/lib/python3.5/_bootlocale.py _future_ | /usr/local/lib/python3.5/_future_.py Print(''.format(module, module))įor the CPython3.5 (truncated) $ python3.5 python_modules_info.py Line = '-' * shutil.get_terminal_size().columns Loaders.append((module.name, module.origin))įor module_name in er_modules(): # add a name and a location about imported module in the dict # add a key about a loader in the dict, if not exists yet # find an information about a module by name This_module_name = os.path.basename(_file_).rsplit('.')įor module_name in sys.builtin_module_names: ![]() Raise NotImplementedError('CPython 2 is not supported yet') ExtensionFileLoader - an importer for modules as shared library (written on the C or C++).SourceFileLoader - an importer for a standard Python module (by default has extension *.py) ( docs).BuiltinImporter - an importer for built-in modules ( docs)._spec() - returns an information about importing module, if exists.er_modules() - returns an information about all available modules.sys.builtin_module_names - names all built-in modules (look my answer here).This solution is primary based on modules importlib and pkgutil and work with CPython 3.4 and CPython 3.5, but has no support for the CPython 2. I could not find any reference to this issue in the documentation. If we run the aforementioned solution from /tmp/behave > import pipīehave=1.2.5a1 is missing from the second example, because the working directory contains behave's setup.py file. If we run the aforementioned solution from /tmp > import pip Installed /private/tmp/test_env/lib/python2.7/site-packages/enum34-1.0-py2.7.eggįinished processing dependencies for behave=1.2.5a1 (test_env) $ cd /tmp/behave & pip install. Install the python package from the git repo We have behave's setup.py in /tmp/behave: (test_env) $ ls /tmp/behave/setup.py Remote: Total 4350 (delta 0), reused 0 (delta 0) Remote: Reusing existing pack: 4350, done. New python executable in test_env/bin/pythonĬlone a git repo with setup.py (test_env) $ git clone I have noticed a strange behaviour of this technique - when the Python interpreter is invoked in the same directory as a setup.py file, it does not list the package installed by setup.py. I added the result of this call to my flask server, so when I call it with I get the list of packages installed on the server's virtualenv. This solution applies to the system scope or to a virtual environment scope, and covers packages installed by setuptools, pip and ( god forbid) easy_install. Installed_packages_list = sorted(["%s=%s" % (i.key, i.version)Īs a (too long) one liner: sorted() Installed_packages = pip.get_installed_distributions() My 50 cents for getting a pip freeze-like list from a Python script: import pip ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |