Python uninstall site packages

How to Uninstall Python Packages

All Python package management solutions provide the basic function of uninstalling packages, including pip, pipenv and the ActiveState Platform. However, unless specifically defined in a requirements.txt or pipfile.lock, package managers will not deal with transitive dependencies (ie., dependencies of dependencies).

In this article, we explain how to uninstall Python packages using these popular tools and we also introduce you to the ActiveState Platform. The AS Platform is unique in automatically installing and uninstalling transitive dependencies. Our dependency management system makes it possible to track conflicts between packages, know about platform-specific dependencies, and even track system-level dependencies like C and C++ libraries. Once you are done reading, you can try the ActiveState Platform by signing up for a free account .

Read on to understand how to work with Pip and Pipenv Package Managers to uninstall Python packages.

Checklist

Before packages can be uninstalled, ensure that a Python installation containing the necessary files needed for uninstalling packages is in place. Installation Requirements (for Windows).

How to Uninstall Packages Installed with Pip

How to Uninstall Packages in a Python Virtual Environment

Packages can be uninstalled from a virtual environment using pip or pipenv.

Читайте также:  Script php videos youtube

To use pip to uninstall a package locally in a virtual environment:

  1. Open a command or terminal window (depending on the operating system)
  2. cd into the project directory
  3. pip uninstall

To use pipenv to uninstall a package locally in a virtual environment created with venv or virtualenv:

  1. Open a command or terminal window (depending on the operating system)
  2. cd into the project directory
  3. pipenv uninstall

How to Globally Uninstall Python Packages

In some cases, packages may be installed both locally (e.g., for use in a specific project) and system-wide. To ensure a package is completely removed from your system after you’ve uninstalled it locally, you’ll also need to uninstall it globally.

To uninstall a package globally in Windows:

    1. Open a command window by entering ‘cmd’ in the Search Box of the Task bar
    2. Press Ctrl+Shift+Enter to gain Administration (Admin) privileges
    3. pip uninstall

    To uninstall a package globally in Linux:

    How to Uninstall Package Dependencies with Pip

    When you install a package with pip, it also installs all of the dependencies the package requires. Unfortunately, pip does not uninstall dependencies when you uninstall the original package. Here are a couple of different procedures that can be used to uninstall dependencies.

    1. If a package has been installed via a pip requirements file (i.e., pip install requirements.txt ), all of the packages in requirements.txt can be uninstalled with the following command:
    pip uninstall requirements.txt
    1. If a requirements.txt file is not available, you can use the pip show command to output all the requirements of a specified package:

    Output should be similar to:

    These dependencies can then be uninstalled with the pip uninstall command. However before uninstalling, you should ensure that the packages are NOT dependencies for other existing packages.

    How to Uninstall Package Dependencies with Pipenv

    To uninstall all the dependencies in a Pipenv project:

    1. Open a command or terminal window
    2. cd into the project directory
    3. pipenv uninstall —all

    How to Uninstall a Package Installed With Setuptools

    Any packages that have been configured and installed with setuptools used the following command:

    Unfortunately, there is no python setup.py uninstall command. To uninstall a package installed with setup.py, use the pip command:

    Be aware that there are a few exceptions that cannot be uninstalled with pip, including:

    • Distutils packages, which do not provide metadata indicating which files were installed.
    • Script wrappers installed by the setup.py develop command.

    Next Steps

    Resolving packages when installing or uninstalling an environment can be an extremely slow (or even manual) process. You can speed things up considerably using the ActiveState Platform, which automatically resolves dependencies for you–fast! Get started free on the ActiveState Platform.

    Or just install Python 3.9 and use the included command line interface, the State Tool, to “state install” the packages you need:

    >state install numpy ╔════════════════════╗ ║ Installing Package ║ ╚════════════════════╝ Updating Runtime ──────────────── Changes to your runtime may require some dependencies to be rebuilt. numpy includes 2 dependencies, for a combined total of 8 new dependencies. Building 8/8 Installing 8/8 Package added: numpy

    Источник

    Removing site-packages for corrupted paths?

    There is one path I need to remove that is the site.package . I’m unsure is it safe to remove the site.package for certain installed software, Django, Virtualenv with out breaking the system. Is Synaptic Package Manager needed?

    1 Answer 1

    It appears that the main reason for the corrupted paths is that the motherboard on the laptop that is being used is damaged which is causing many different types of errors.

    The way to fix this problem on good hardware does not require reinstalling Ubuntu. Open the terminal and type:

    The results of ls /usr/lib/python3.7 may show a directory named site.packages. The site.packages directory may contain several directories in it which have Python packages that you may have installed with pip3 to use in your Django project in Ubuntu 19.04 for which python3.7 is the base interpreter. Let’s look at an example. Let’s suppose that there is a directory in the site.packages directory named Django. If such a directory exists, then it was installed by pip3. To uninstall this instance of Django that was installed by pip3 run:

    sudo pip3 uninstall Django 

    Please note that you must use sudo in the above command because the /usr/lib/python3.7/site.packages directory is owned by root. If the site.packages directory is located in your home folder, then it is not owned by root and you don’t need to use sudo to uninstall a Python package from this directory. You could uninstall a Python package from this directory with a command of the form pip3 uninstall package-name

    Источник

    How to Uninstall a Package in Python using PIP

    Data to Fish

    In this short tutorial, you’ll see how to uninstall a package in Python using PIP.

    If you’re using Windows, you’ll be able to uninstall a Python package by opening the Windows Command Prompt, and then typing this command:

    pip uninstall package_name

    Note : the above method would only work if you already added Python to Windows path. Don’t worry if you don’t know what it means, as you’ll see the full steps to uninstall a package in Python from scratch.

    Steps to Uninstall a Package in Python using PIP

    (1) First, type Command Prompt in the Windows Search Box

    (2) Next, open the Command Prompt, and you’ll see the following screen with your user name (to avoid any permission issues, you may consider to run the Command Prompt as an administrator ):

    (3) In the Command Prompt, type “cd\” as this command will ensure that your starting point has only the drive name:

    (4) Press Enter. Now you’ll see the drive name C:\>

    (5) Locate your Python Scripts path. The Scripts folder can be found within the Python application folder, where you originally installed Python.

    Here is an example of a Python Scripts path:

    C:\Users\Ron\AppData\Local\Programs\Python\Python39\Scripts

    (6) In the Command Prompt, type cd followed by your Python Scripts path:

    (7) Press Enter, and you’ll see the following:

    (8) Finally, to uninstall a package in Python, use this command, while specifying the package name that you’d like to uninstall:

    pip uninstall package_name

    (9) To proceed with the removal of the package, type “y” and then press Enter:

    Your Python package will now be removed from Python.

    What if you changed your mind, and decided to install that package again?

    If that’s the case, you may use the PIP install method to add the package into Python.

    Источник

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