Fedora install python packages

Installing pip/setuptools/wheel with Linux Package Managers¶

This section covers how to install pip , setuptools , and wheel using Linux package managers.

If you’re using a Python that was downloaded from python.org, then this section does not apply. See the Requirements for Installing Packages section instead.

Note that it’s common for the versions of pip , setuptools , and wheel supported by a specific Linux Distribution to be outdated by the time it’s released to the public, and updates generally only occur for security reasons, not for feature updates. For certain Distributions, there are additional repositories that can be enabled to provide newer versions. The repositories we know about are explained below.

Also note that it’s somewhat common for Distributions to apply patches for the sake of security and normalization to their own standards. In some cases, this can lead to bugs or unexpected behaviors that vary from the original unpatched versions. When this is known, we will make note of it below.

Читайте также:  Интерпретатор питон vs code

Fedora¶

sudo dnf install python3-pip python3-wheel

To learn more about Python in Fedora, please visit the official Fedora docs, Python Classroom or Fedora Loves Python.

CentOS/RHEL¶

CentOS and RHEL don’t offer pip or wheel in their core repositories, although setuptools is installed by default.

To install pip and wheel for the system Python, there are two options:

    Enable the EPEL repository using these instructions. On EPEL 7, you can install pip and wheel like so:

sudo dnf install python3-pip python3-wheel
sudo dnf install python3-pip python3-wheel
sudo dnf upgrade python3-setuptools

To install pip, wheel, and setuptools, in a parallel, non-system environment (using yum) then there are two options:

  1. Use the “Software Collections” feature to enable a parallel collection that includes pip, setuptools, and wheel.
    • For Redhat, see here: https://developers.redhat.com/products/softwarecollections/overview
    • For CentOS, see here: https://github.com/sclorg

Be aware that collections may not contain the most recent versions.

sudo yum install python34u python34u-wheel

openSUSE¶

sudo zypper install python3-pip python3-setuptools python3-wheel

Debian/Ubuntu and derivatives¶

Firstly, update and refresh repository lists by running this command:

sudo apt update sudo apt install python3-venv python3-pip

Recent Debian/Ubuntu versions have modified pip to use the “User Scheme” by default, which is a significant behavior change that can be surprising to some users.

Arch Linux¶

Currently, there is no “copr” yum plugin available for CentOS/RHEL, so the only option is to manually place the repo files as described.

Table of Contents

  • An Overview of Packaging for Python
  • The Packaging Flow
  • Tutorials
  • Guides
    • Installing packages using pip and virtual environments
    • Installing stand alone command line tools
    • Installing pip/setuptools/wheel with Linux Package Managers
    • Installing scientific packages
    • Package index mirrors and caches
    • Hosting your own simple repository
    • Packaging and distributing projects
    • Including files in source distributions with MANIFEST.in
    • Single-sourcing the package version
    • Dropping support for older Python versions
    • Packaging binary extensions
    • Packaging namespace packages
    • Creating and discovering plugins
    • Using TestPyPI
    • Making a PyPI-friendly README
    • Publishing package distribution releases using GitHub Actions CI/CD workflows
    • Tool recommendations
    • Analyzing PyPI package downloads

    Previous topic

    Next topic

    © Copyright 2013–2020, PyPA.
    This page is licensed under the Python Software Foundation License Version 2.
    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.

    The Python Software Foundation is a non-profit corporation. Please donate.

    Last updated on Jun 16, 2023. Found a bug?
    Created using Sphinx 4.5.0.

    Источник

    Fedora Developer Portal

    General-purpose, high-level programming language supporting multiple programming paradigms.

    Using pip

    If a Python package you need is not packaged for Fedora, or if you need it in an isolated environment, you can use pip to install it from the Python Package Index (PyPI).

    Note that software on PyPI is not part of Fedora, and has different standards of quality, security and licensing: essentially, anyone can upload code there. Only install software you trust, and always double-check install commands for typos in package names.

    You can either install such modules to a virtual environment, or to your home directory with the —user user switch. See below for both options.

    Installing modules with pip to system directories is not recommended, as it can override system libraries and lead to an unstable system.

    Using pip in the virtual environment

    The best practise is using pip in the virtual environment. It will keep all modules for one project at one place and it will not break your local system. Another advantage is that you can have more versions of the same module in different virtual environments.

    Let’s create a virtual environment called project_venv with the main Python 3 version in Fedora. If you need to use another version of Python or a different interpreter such as PyPy, see the Multiple Interpreters section.

    $ python3 -m venv project_venv 

    If you want to work in the virtual environment, you have to activate it.

    $ source project_venv/bin/activate 

    When the virtual environment is activated (you can see it’s name in brackets at the beginning of your prompt), you can install modules with pip. For example, if your project needs the requests library, run:

    (project_venv) $ python -m pip install requests 

    When you finish your work, just deactivate the virtual environment.

    The environment is a directory. If you no longer need it, deactivate it and delete it with rm -rv project_venv .

    User-specific installation

    Sometimes, you don’t want to use a virtual environment. For example, you’re installing a tool you will use in multiple projects, but the tool is not available in Fedora repositories. In such cases, you might need to install pip if you do not already have it system-wide:

    $ sudo dnf install python3-pip 

    Then, use pip’s —user option. For example, to install a Python implementation of cowsay (rather than the original Perl one available in Fedora), run:

    $ python -m pip install --user cowsay 

    Updating packages

    Since software installed using pip is not part of Fedora, it is your responsibility to keep it updated as needed. However you ran pip install , running it again with —update will update to the latest release. For example, to update the requests library:

    (project_venv) $ python -m pip install --update requests 

    What next?

    Share your knowledge

    Fedora Developer Portal is a community effort to share guides and information about open-source development. And we need your help!

    Источник

    Fedora Developer Portal

    General-purpose, high-level programming language supporting multiple programming paradigms.

    Python in Fedora

    Python is a widely used, interpreted, object-oriented, high-level programming language with dynamic semantics. It is simple and easy to learn. Python 3 is already pre-installed on Fedora. Let’s use it!

    Running Python

    1. Open your terminal. (In GNOME, press Alt + F1 , type Terminal and press Enter .)
    2. To run Python, type python Enter . You should see something like this:
    Python 3.9.0 (default, Oct 6 2020, 00:00:00) [GCC 10.2.1 20201005 (Red Hat 10.2.1-5)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 

    Now you can start to write in Python! Let’s print Hello World!

    If you want to exit Python, press Ctrl + D .

    To run a program written in Python, type python followed by the file name of the program. Like this:

    In some guides, you will see python3 used instead of python . These commands are equivalent. You can also run a more specific version of Python, like python3.9 , if you have that interpreter installed. See the Multiple Interpreters section for details.

    Python packages

    Fedora contains many popular packages for Python. Usually, they are named with a python3- prefix, such as python3-requests .

    These are useful for scripting and exploring Python and for Fedora-specific applications. For software development or reproducible data analysis, it is better to use virtual environments.

    Using virtual environments

    When you work on a project, it is good to keep it inside a virtual environment. It will keep the dependencies you need in one place and you do not have to worry about different projects which need different versions of the same module. It also makes it easy to collaborate with people who don’t use Fedora yet.

    Let’s create a virtual environment called project_venv which will contain Python and pip. You can use pip to install a project’s dependencies.

    $ python -m venv project_venv 

    If you want to work in the virtual environment, you have to activate it.

    $ source project_venv/bin/activate 

    When the virtual environment is activated (you can see its name in brackets at the beginning of your prompt), you can install modules via pip install .

    (project_venv) $ python -m pip install requests 

    That is all, you have successfully created your own virtual environment. Now you can run Python (see above) and start working on your project.

    When you finish your work, you can deactivate the virtual environment.

    Note that packages installed system-wide are not available in the virtual environments: by default, virtual environments are isolated from the system. As an alternative, you can create the environment with —system-site-packages – but note that when you update your Fedora packages, they may get out of sync with modules installed inside the environment.

    What next?

    Share your knowledge

    Fedora Developer Portal is a community effort to share guides and information about open-source development. And we need your help!

    Источник

    How to Install Python Package Installer PIP on Fedora 38

    PIP is mainly used to install new Python packages/libraries/modules from the official Python PyPi package repository on your computer.

    In this article, we will show you how to install PIP on the Fedora 38 operating system. We will also show you how to upgrade PIP to the latest version in Fedora 38.

    Topic of Contents:

    Updating the Fedora 38 Package Repository Cache

    First, update the package repository cache of Fedora 38 with the following command:

    The package repository cache of Fedora 38 should be updated.

    Installing PIP on Fedora 38

    Python PIP is available in the official package repository of Fedora 38. So, it is easy to install.

    To install the Python PIP on Fedora 38, run the following command:

    To confirm the installation, press Y and then press .

    Python PIP is now being downloaded from the official package repository of Fedora 38. It takes a few seconds to complete.

    If you see the following prompt, press Y and then press to accept the GPG key of the Fedora 38 package repository.

    Python PIP should now be installed.

    Checking If PIP is Working on Fedora 38

    To check whether you can access PIP and if PIP is working on Fedora 38, run the following command:

    If PIP is accessible and it’s working, the installed version number of PIP should be printed. At the time of this writing, Fedora 38 has PIP 22.3.1 in its package repository. The newer versions of PIP may be available. You might want to upgrade it to the latest version. We will show you how to do that in the next section of this article.

    How to Upgrade PIP to the Latest Version in Fedora 38

    To check whether a newer version of PIP is available and upgrade PIP to the latest version in Fedora 38, run the following command:

    PIP should be upgraded to the latest version if the newer version of PIP is available in the PyPi package repository.

    To check the version number of PIP after the upgrade, run the following command. As you can see, PIP was upgraded to 23.1.2 from 22.3.1. By the time that you read this article, you may get a newer version of PIP than 23.1.2.

    How to Use PIP to Manage the Python Packages/Modules

    If you want to know more about PIP and how to use it, we recommend you to read the article on How to Manage the Python Packages with PIP. In this article, we will show you how to install the new Python packages, list the installed Python packages, uninstall the Python packages with PIP, and so on.

    Conclusion

    We showed you how to install Python PIP on the Fedora 38 operating system. We also showed you how to upgrade PIP to the latest version in Fedora 38.

    About the author

    Shahriar Shovon

    Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.

    Источник

Оцените статью