应该
你正在下载“
"? 这是一个可行和切实可行的解决办法吗?我不这么认为,原因如下:
-
上提供的python包的数量
PyPi
,这是大多数包的宿主。在我写这个答案时,有“278688个项目”可供选择。(注意:我知道还有其他网站可以下载软件包,但是为了回答这个问题,让我们只关注PyPi)。
-
具体的
pandas 1.1.5 depends on NumPy 1.15.4
在其他依赖项中。
-
并非所有软件包都与您的Python版本(例如,有些软件包仅适用于Python 2,您正在使用Python 3)、操作系统版本(例如,需要Windows api或Linux api)或其他特定于环境的配置(例如,需要
gcc
编译)。所以,你可能需要下载一些其他的
东西
-
As mentioned in Klaus D's. comment
,您还需要每个下载包的文档。您需要它们作为包使用和解决任何问题/错误的参考。您只能希望包api具有适当的
__doc__
help(module.function)
或者你的IDE可以用intellisense显示给你。
考虑到这些因素,有一种方法
尝试
假设您有时间、网络带宽和磁盘容量将它们全部存储在您的计算机上,就可以从PyPi“下载它们”。你可以:
下面是一个示例Python脚本:
# Dependencies: pip install requests beautifulsoup4
# Tested on Python3.8.6, beautifulsoup4==4.9.3, requests==2.25.1
import random
import requests
import subprocess
from bs4 import BeautifulSoup
pypi_index = 'https://pypi.python.org/simple/'
print(f'GET list of packages from {pypi_index}')
try:
resp = requests.get(pypi_index, timeout=5)
except requests.exceptions.RequestException:
print('ERROR: Could not GET the pypi index. Check your internet connection.')
exit(1)
print(f'NOW parsing the HTML (this could take a couple of seconds...)')
try:
soup = BeautifulSoup(resp.text, 'html.parser')
body = soup.find('body')
links = (pkg for pkg in body.find_all('a'))
except:
print('ERROR: Could not parse pypi HTML.')
exit(1)
# As a demo, I'm just going to install 5 random packages
# If you *really* want to install them all, remove this
# limit and the sampling of 'list(links)'
install_limit = 5
some_of_the_links = random.sample(list(links), install_limit)
for link in some_of_the_links:
pkg_name = link['href'].split('/')[-2]
cmd = f'pip install {pkg_name}' # Replace with `conda` for Anaconda
print("=" * 30)
print(f'NOW installing "{pkg_name}"')
try:
subprocess.run(cmd.split(), check=True)
except subprocess.CalledProcessError:
print(f'ERROR: Failed to install {pkg_name}')
continue
注意,我限制了脚本只安装5个随机软件包。拆下
install_limit
但请注意,并不是每个安装都会成功,因为正如我在一开始所说的,有些安装已损坏,或者与您的系统不兼容,或者彼此不兼容。
“全部下载”的其他替代方法是:
方案1
可能地
需要。例如,您计划使用Excel文件,然后搜索
reading excel files in Python
方案2
您可以在此处查询从PyPi下载最多的软件包:
https://pypistats.org/top
PyPi Stats API
得到一个更精确的列表。
datascience-notebook
,其中“
包括用于Julia、Python和R社区数据分析的库。
". 对于web应用程序,有以下几种
tiangolo/uvicorn-gunicorn-fastapi
用于使用Uvicorn Gunicorn FastAPI堆栈构建web应用程序。根据用例的不同,还有很多。您可以将这些图像用作所需Python包的参考,或者直接将它们用作开发环境。
$ docker pull jupyter/datascience-notebook
$ docker run -it jupyter/datascience-notebook bash
(base) jovyan@fdaf7dd9db33:~$ pip list
Package Version
----------------------------- -------------------
alembic 1.4.3
argon2-cffi 20.1.0
async-generator 1.10
attrs 20.3.0
backcall 0.2.0
backports.functools-lru-cache 1.6.1
beautifulsoup4 4.9.3
bleach 3.2.1
blinker 1.4
bokeh 2.2.3
Bottleneck 1.3.2
...