我在试着读gitlab的文件。我在gitlab中为此创建了访问令牌。下载的模块python
我从:PyCharm:->Settings-> Python解释器->python安装了PyCharm模块python。
import gitlab
import json
from pprint import pprint
import requests
import urllib.request
# private token authentication
gl = gitlab.Gitlab('https://gitlab.com/..../CSV_HOMEWORK.csv', private_token='xxx')
gl.auth()
# list all projects
projects = gl.projects.list()
for project in projects:
# print(project) # prints all the meta data for the project
print("Project: ", project.name)
print("Gitlab URL: ", project.http_url_to_repo)
# print("Branches: ", project.repo_branches)
pprint(project.repository_tree(all=True))
f = urllib.request.urlopen(project.http_url_to_repo)
myfile = f.read()
print(myfile)
print("\n\n")
打印后(Gitlab)我有
我运行代码的文件名不是gitlab.py
发布于 2022-02-28 01:08:41
您安装了包gitlab
而不是python-gitlab
。
即使您已经安装了python-gitlab
,gitlab
包仍然会发生冲突,因此必须卸载它。
pip uninstall gitlab
pip install python-gitlab
https://stackoverflow.com/questions/71284958
复制相似问题