'module 'gitlab' has no attribute 'Gitlab'

I am trying to read the file from gitlab. I created access token in gitlab for this. Downloaded module python-gitlab

I installed module python-gitlab from PyCharm: File --> Settings--> Python interpreter --> python-gitlab

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")

after print(gitlab) I have enter image description here

P.S. My file name from where I run my code isn't gitlab.py



Solution 1:[1]

You installed the package gitlab instead of python-gitlab.

Even if you installed python-gitlab already, the gitlab package will still conflict, so it must be uninstalled

pip uninstall gitlab
pip install python-gitlab

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sytech