howie@howie:~/pl-predictions-using-fifa$ pip list
Package Version
----------------------------- ----------------------
apturl 0.5.2
autopep8 1.4.3
beautifulsoup4 4.4.1
blinker 1.3
Brlapi 0.6.4
certifi 2018.11.29
chardet 3.0.4
checkbox-support 0.22
command-not-found 0.3
cryptography 1.2.3
defer 1.0.6
Deprecated 1.2.4
feedparser 5.1.3
get 2018.11.19
gitdb2 2.0.5
GitPython 2.1.11
guacamole 0.9.2
html5lib 0.999
repo_entry = {}
repo_entry['name'] = 'Python Fifa.git'
repo_id = repo_coll.insert_one(repo_entry).inserted_id
output, error = process.communicate()
data = json.loads(output.decode('UTF-8'))
for v in data['Package'].values():
if 'Version' in v.keys():
db_entry = {}
db_entry['name'] = v['Package']
db_entry['version'] = v['Version']
db_entry['repo_id'] = repo_id
dep_coll.insert_one(db_entry)
cursor = dep_coll.find({'repo_id': repo_id})
for document in cursor:
print(document)
嗨,我正在尝试列出python项目的依赖项。我使用pip list来执行此操作,pip list输出一个项目需要的依赖项列表。我可以使它正常工作,但是在我的脚本中,我想获取该输出并将其安装到mongo DB中。第二部分是我为此编写的代码。它似乎不起作用。如果有人有任何想法,将不胜感激。