大家好!今天给你们带来了高效的管理pip库工具,可以帮我们提高工作效率,其功能有搜索、获取某库所在位置、安装、卸载等等。
安装:
pip install wherepip
1.
命令方式使用
:
whereis requests #输出requests所在目录
fuck requests #卸载requests
befuck requests #安装requests
so re #搜索re为关键词的库
all #输出所有python库
2.Python实例:
import wherepip
r=wherepip.whereis("requests")
s=wherepip.so("py")
a=wherepip.all()
wherepip.fuck("requests")#卸载
wherepip.befuck("requests")#安装
print(s)
print(a)
print(r)
------------------------------------------------------------------------
源代码(自用):
#By Python_Fucker On 2024/6/11
import subprocess
import sys
import pkg_resources
defwhereis(s=None):
if s==None:
s=sys.argv[1]
return __import__(s).__path__[0]
deffuck(s=None):
if s==None:
s=sys.argv[1]
subprocess.check_call([sys.executable, '-m', 'pip', 'uninstall', s, '-y'])
defbefuck(s=None):
if s==None:
s=sys.argv[1]
subprocess.check_call([sys.executable, '-m', 'pip', 'install', s])
defso(s=None):
if s==None:
s=sys.argv[1]
results = []
for pkg in pkg_resources.working_set:
if s.lower() in pkg.project_name.lower() or s.lower() in pkg.version.lower():
results.append(f"{pkg.project_name}=={pkg.version}")
return results
defall():
installed_packages = list(pkg_resources.working_set)
results = []
for package in installed_packages:
results.append(f"{package.project_name}=={package.version}")
return results
配置文件:
from setuptools import setup
withopen('README.md', 'r', encoding='utf-8') as f:
long_description = f.read()
setup(
name='wherepip',
version='1.0.8',
description='高效python库管理工具,功能有搜索、安装、卸载、获取库所在目录(python学霸公众号)',
long_description=long_description,
long_description_content_type='text/markdown',
author='Python学霸',
author_email='[email protected]',
py_modules=['wherepip'],
install_requires=[],
entry_points={
'console_scripts': [
'whereis=wherepip:whereis',
'fuck=wherepip:fuck',
'befuck=wherepip:befuck',
'so=wherepip:so',
'all=wherepip:all'
]
}
)
README.MD:
## 介绍
`wherepip`是一个高效pip管理工具,帮你节省更多时间!
## 使用
**1.命令方式**
``` bush
whereis requests #输出requests所在目录
fuck requests #卸载requests
befuck requests #安装requests
so re #搜索re为关键词的库
all #输出所有python库
```
**2.Pyhton使用**
``` python
import wherepip
r=wherepip.whereis("requests")
s=wherepip.so("py")
a=wherepip.all()
wherepip.fuck("requests")#卸载
wherepip.befuck("requests")#安装
print(s)
print(a)
print(r)
```
**喜欢关注python学霸微信公众号!**