This question already has answers here:
Is there a way to list pip dependencies/requirements?
(10 answers)
Closed 4 years ago.
I need something like the following:
pip showrequirements tensorflow
This would return something that allows me to parse the names of the required packages and the required versions:
astor>0.6, tensorboard>1.0.11, etc.
pip is getting this information in some form during the install and download command. I can see where it's happening in the code... but before I hack my way to using pip's internal code, is there any easy API or existing library that can do this?
edit: I cannot install the package to see this, so pip show won't work. One (hacky) solution is parsing the output of pip download.
Thanks!
pip show <package_name>
will list the dependencies in the "Requires" section. See documentation.
Edit:
pip show only works for installed packages. For uninstalled packages, PyPI has a JSON API.
For example:
import json
import requests
package_name = 'tensorflow'
url = 'https://pypi.python.org/pypi/' + str(package_name) + '/json'
data = requests.get(url).json()
print(data['info']['requires_dist'])
So there used to be a --no-install flag in older version of pip, but no longer. pip show will show you the "Requires" property, but only for packages installed in your environment (system or in your venv), where it seems you wanna check out requirements before you install. So, sadly, I think there's not a nice way to accomplish what you're looking for.
Related
This question already has answers here:
What is the purpose of "pip install --user ..."?
(9 answers)
Closed 8 months ago.
Since company's computer require admin right / presmission when installing anythings, is there any method using extend python libraries without installing (e.g. selenium, requests, beautifulsoup4, PyPDF2 and OpenPyXL).
Go to PyPI
find your package,
go to the Home at the left sidebar (most of them redirected to GitHub or GitLab)
then download the repository and install the package locally, something like this:
pip install /home/yourname/requests
pip install directory_of_setup.py
or use the package without installing it, import the source code to your project
I'm new to python, about a month.
I know installing python modules can be done by using pip or easy_install. But when I was trying to install the regex module it gave me an error.
Typing pip install re in cmd gave me the following errors;
ERROR: Could not find a version that satisfies the requirement re (from versions: none)
ERROR: No matching distribution found for re
So I went to PyPI and downloaded a file there and now PyCharm doesn't give error when I import the module anymore.
So are there any difference between these ways of downloading Python modules or it doesn't matter ?
I'm using Windows 10 and have Python 3.8 and 3.8.1.
re is a built-in module, therefore you are not required to install this with pip.
Python Built-In Modules
re is part of the Python standard library so there is no need to install it separately. There are many ways to 'install' a package, e.g. using easy_install, pipx, venv, poetry, etc., but pip install --user is likely the way you're going to want to go to get started until you run into a compelling reason to explore other options. Either way, all these tools are essentially just various ways to move packages into PYTHONPATH, the place that Python looks for packages by default.
I have installed python 3.7.0 and my installation directory is AppData\Local\Programs\Python\Python37-32
Now I have tried to upgrade pip with:
python -m pip install –upgrade pip'
and I got:
Successfully installed pip-19.0.3
I did pip install ijson(while I was in folder AppData\Local\Programs\Python\Python37-32\Scripts) and double checked with the result being:
Requirement already satisfied: ijson in c:\users\myusername\appdata\local\programs\python\python37-32\lib\site-packages (2.3)
But when I go to my PyCharm project and I import ijson it can't find the module.Just to be clear if I import json or any other module I can work with it.
I know this has some duplicates and I have seen some of them. I have tried everything for example on these and others. Just for reference (possible duplicate)(possible dublicate 2)
but I haven't been able to solve my issue. Please tell me if I am missing something, maybe it is connected to the interpreter I am using or a wrong installion of python.
Thank you in advance
Make sure the python interpreter you are using in Pycharm is the one where you install ijson via pip.
You can do this by looking at the interpreter path in PyCharm, then opening that path in your terminal and trying import ijson
Also make sure the pip you are using is connected to the python interpreter you are using in PyCharm
I am working with Scrapy framework to scrap out data from website, but getting the following error in command prompt:
ImportError: cannot import name '_win32stdio'
Traceback is attached as a screenshot.
Kindly revert if require directory structure of my program's directory.
Scrapy can work with Python 3 on windows if you make some minor adjustments:
Copy the _win32stdio and _pollingfile to the appropriate directory under site-packages. Namely, twisted-dir\internet. Download these from https://github.com/twisted/twisted/tree/trunk/twisted/internet
pip install pypiwin32
Granted, this is based on my personal experience. Because the repository will certainly change in the future, readers should beware the age of this answer.
Update: the twisted-win package is no longer required because the appropriate files are now included in the twisted package.
I have gone through the same. I have resolved by updating the twisted package
pip install --upgrade twisted
or
pip uninstall twisted and pip install twisted
get whl of twisted (from below link) according to your os and py version and you are good to go!
https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted
I'm trying to remove a package I apparently installed sometime ago (can't remember really) and I'm finding it harder than I thought it would be (the package's name is astropy).
If I do:
import pip
inst_packgs = pip.get_installed_distributions()
inst_packgs_lst = ["%s" % (i.key) for i in inst_packgs]
print inst_packgs_lst
the package is listed as installed.
but if I try:
pip list
the package is not listed as installed.
If I do:
pip search astropy
the package is listed as an available package in PyPi.
If I try:
pip uninstall astropy
I get:
Cannot uninstall requirement astropy, not installed
Storing debug log for failure in /home/gabriel/.pip/pip.log
Why is this not working? How should I remove this package from my system?
UPDATE
pyenv is installed in my system and it was set to a different version locally, which is why the package didn't show. Sorry everybody, this question should be closed/deleted.
https://pip.pypa.io/en/latest/reference/pip_search.html
pip search your_query
"searchs for PyPI packages whose name or summary contains your_query".
astropy exists in PyPI but is not installed in your system
Try :
pip list
instead to get a list of installed packages.
Answering my own question for completeness sake.
pyenv was installed in my system and it was set to a different version locally, which is why the package didn't show.