Ignore certain packages and their dependencies with pip freeze

Related searches

Title basically says it all. How can I tell pip freeze to ignore certain packages, like pylint and pep8, and their dependencies?

There are few options available

Try simple ignorance

Simply do not care about these packages being present in pip output.

Delete these lines from output

Filter the output through some grep filter and have the result clean.

Use virtualenv and do not install unwanted packages into it

Note, that pip freeze in virtualenv does not report globally installed packages (however it typically reports argparse and wsgiref for me - nothing seems to be really perfect.)

Write your own pipwarm command

which would call pip freeze and modify the output as needed (removing unneeded files).

I am aware, I probably did not give you the answer you asked for, but maybe the virtualenv is close to what you need, as it allows global presence of those packages and still allow not having these packages in output of pip freeze.

Install pep8 and pylint as scripts but keep them away from pip visibility

In case, you just care about having pylint and pep8 available as command line tools, but do not require them visible to pip freeze, there are multiple options

Install pep8 and pylint into virtualenv and copy the scripts to /usr/bin

If you install pylint and pep8 into separate virtualenv, find location of the executables by which pep8 and which pylint and copy these files somewhere, where they will be visible, e.g. to /usr/bin. The scripts you copy or move from virtualenv have hardcoded path to required python packages in the virtualenv and will safely run even when copied (just the scripts, do not touch the rest of related virtualenv). Note, that there is no need to activete given virutalenv to make that working.

Install pep8 and pylint system wide but keep developing in virtualenv

System wide installed command line tools are typically installed into location, which makes them globally visible. At the same time, system wide installed packages are not seen by pip freeze when called in virtualenv.

pip freeze — pip 20.2.2 documentation, pip freeze [options]. Description�. Output installed packages in requirements format. packages are Use the order in the given requirements file and its comments when generating output. This option Exclude editable package from output. I want to exclude specific dependencies since they are already met from a different install path (e.g. an anaconda install). I don't have the privilege of adding packages to the default python installation (nor do I want to). I'm currently use the -r and -t options of pip. But have not found a way to exclude specific packages. A pip command

My approach is the following:

  1. I my .bashrc I create the following alias: alias pipfreezeignore='pip freeze | grep -vFxf ignore_requirements.txt'
  2. Create the virtual environment, and install first all the packages that I do not want to keep track of (i.e. pip install jedi flake8 importmagic autopep8 yapf).
  3. Immediately save them in a ignore_requirements.txt file, as in pip freeze > ignore_requirements.txt.
  4. Install the rest of packages (e.g. pip install django)
  5. Use pipfreezeignore > requirements.txt (in the same folder where ignore_requirements.txt is) so I just get in requirements.txt the installed packages that are not in ignore_requirements.txt

If you always want to ignore the same packages (through all your virtual environments), you might redefine the alias as in alias pipfreezeignore='pip freeze | grep -vFxf /abs/path/to/ignore_requirements.txt' Just make sure that no packages from ignore_requirements.txt are not actually necessary for your project.

`$ pip freeze > requirements.txt` considered harmful, There are few dangers to this approach, mainly that libraries have level dependency on some package (which one is very hard to know, requirements- freeze.txt and exclude our direct dependencies from that resulting list. Currently using pip freeze will only show the final package list of dependencies. I would recommend using pipdeptree module which helps to find possible dependency conflicts and displaying an

on windows with powershell:

 $exclude = 'pylint', 'pep8'  

 pip freeze |  
             Where-Object { $exclude -notcontains $_ } |  
             ForEach-Object { pip install --upgrade $_ }

Do not exclude legitimately installed packages from pip freeze #1610, Do not exclude legitimately installed packages from pip freeze #1610 as a requirement were given in answers to my recent question Is there any sense to put like pip freeze that locks down the full set of dependencies and� Only output packages installed in user-site.--path <path>¶ Restrict to the specified installation path for listing packages (can be used multiple times).--all¶ Do not skip these packages in the output: setuptools, wheel, pip, distribute--exclude-editable¶ Exclude editable package from output.

Option in pip freeze operation to exclude version info?? � Issue , When running pip freeze the default output shows all the package names the dependencies makes me have 78 packages so for me its useless for either Use case - For some having a specific package version serve no� All packages and packages summaries containing search term are included in the result. Usage - pip search boot. pip check. This command is used verify whether installed packages have compatible dependencies. Usage - pip check. pip uninstall. Unnecessary packages could be cleaned up from the target machine using this command.

Manage package dependencies with a requirements.txt file, The most common command is pip freeze > requirements.txt , which records installing a package), but Visual Studio provides specific support for In this case, manually edit the file to exclude this package or to use pip's options to to compile a dependency and add the --find-links <path> option to your� Due to conflicting dependencies pip cannot install package_coffee and package_tea:-package_coffee depends on package_water < 3.0. 0, >= 2.4. 2-package_tea depends on package_water == 2.3. 1 In this example, pip cannot install the packages you have requested, because they each depend on different versions of the same package ( package_water ):

Problem is, as I upgraded some packages, some dependencies are no longer used nor required but they keep being listed by pip freeze. Now, I'd like to set up a new virtualenv this way: put the needed packages (without their dependencies) in a requirement file,

Comments
  • The virtualenv is part of the problem. I have to install certain utility programs like pylint and pep8 into the virtualenv to be able to fully check the source code with them, but I do not want to deploy them to the server. This is Heroku, so deployment involves a pip freeze > requirements.txt. Thus, this leaves me with my current solution, which is to manually discover their dependencies through something like a fake pip install, then manually delete all the lines with vim, or just ignore it.
  • @Two-BitAlchemist Do you really need these packages to be available for import, or it is enough to have it available as command line tool?
  • @Two-BitAlchemist here you are. Answer extended to cover installation of command line tools in such a way, they are usable, but do not spoil our pip freeze output.
  • Unfortunately, the globally installed pylint will also create a ton of spam about failing imports because it is outside the virtualenv and can't see them on the path.
  • Decided to accept because even though I was ultimately disappointed with the solution, I essentially went with your first option, simply declining to care that they are included in the output and needlessly installed.
  • Wow, what an elegant solution! With a bit of work this could even become a tool that tracks the dependencies of the rest of packages, so that if there's a dependency from your packages in common with any dependency of your ignored packages, it would not ignore it, as it'd be required for the project.