Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"import Credentials as cr" gives problems when running code #2

Open
TheJollyDuck opened this issue Jan 8, 2021 · 2 comments
Open

Comments

@TheJollyDuck
Copy link

Hello. I'm trying to run your code to try and generate the CSV file with the necessary data for later on. I've been trying to resolve the issues with one of the modules that are required in both main.py and GetTwitchData.py : import Credentials as cr.

I've tried many methods to get it to work. I tried reinstalling and removing older python versions to prevent any problems with them. I installed the other necessary modules such as requests & pandas and pip doesn't seems to give much issue to installing credentials as well. I've tried running it through the command prompt as well and through PyCharm and I do still get an error.

File "FILE_LOCATION\GetTwitchData.py", line 5, in <module>
import Credentials as cr
ModuleNotFoundError: No module named 'Credentials'

I thought there wasn't supposed to be a capital for Credentials, so I tried import credentials as cr, which changed the type of problem. Instead I get errors like this:

File "FILE_LOCATION\GetTwitchData.py", line 16, in GetTopStreams
Headers = {'Client-ID': cr.clientID, 'Authorization': "Bearer " + cr.clientSecret}
AttributeError: module 'credentials' has no attribute 'clientID'

At this point, I'm sure that it is Credentials and not all lowercase. In this case, I'm not sure what to do now. Pip doesn't have that package and PyCharm still highlights it as non-existant.

Could you shed some light on this? This might be something on my end though I'm not so sure.

@KiranGershenfeld
Copy link
Owner

Hi, thanks for reaching out. Sorry you had to go through so much trouble for something that is such a silly issue. The Twitch API needs two credentials: a "client ID" and a "client secret". You will need to get your own versions of these credentials in order to use the API and my script. In order to not make my credentials public I put them in a separate python script called "Credentials" and imported that, while putting it in the gitignore for the project so it would not get published. The same thing goes for the path to working directory in "main.py" (I just didnt want to make my personal file paths public).

Heres what you should do:

  1. Go here and generate credentials https://twitchtokengenerator.com/ . You shouldnt need to enable any specific settings.
  2. Copy and paste those credentials in the script where it says cr.clientID and cr.clientSecret.
  3. Remove "import Credentials as cr"
  4. in main.py remove "cr.path" and paste the path to wherever your project is saved (ie. "C:/code/VisualizingTwitchCommunities")

@TheJollyDuck
Copy link
Author

Alright. I got it to work now and the issue is solved, thanks. The next thing for me is to understand how to work Gephi (importing is fine, just the analysis and actually seeing the data properly), the Data Processing file seems straightforward enough. I might make a pull request sometime for some additions on the documentation but tbh I just wanted to see Forsen on a graph similar to the one you made. Getting banned kinda got in the way of that. Thanks for all the help and the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants