kokonut27/Git-API

[BUG] Installing package but not being able to import it

Closed this issue · 34 comments

Describe the bug
Installing it through pip works fine. But then when I run the python file, it raises a ModuleNotFoundError.

C:\Users\---\programing\python>pip install git-api
Requirement already satisfied: git-api in c:\users\---\anaconda3\lib\site-packages (1.0.0)

C:\Users\---\programing\python>python githubapi.py
Traceback (most recent call last):
  File "githubapi.py", line 1, in <module>
    import git_api
ModuleNotFoundError: No module named 'git_api'

Code in githubapi.py:

from git_api import *

# set the token
Token('mytoken123supersecret123') 

user_info = User("Isaiah08-D").User() # Insert your username in the argument shown here.

print(user_info)

You probably want to go into the place where python is installed, and look at the lib dir, where packages are installed. Look for a folder that look like git_api. It will probably not be the same name. The name of the folder is the name of which you need to import

@Isaiah08-D, if you did this in Replit, maybe check the packages section to the left, and install from there. If it is already installed and still does not work, you might want to try going to the shell, and inserting the following:

pip install "git_api"

This may or may not work, but there is a chance that it will probably be the answer to your problem.

Hope this helps!

I was not doing it on replit, but I just tried and it still doesn't work. Here is the repl:
https://replit.com/@isaiah08/AfraidGruesomeArgument @JBYT27

I know an easier way to upload packages to pypi. Can I try to use that? I will keep the code and the credits, just upload it to pypi in a different fashion.

Okay, sure! I'll keep on trying to find a way to make the module upload correctly, this has happened before to a package I have made, and I did fix it, I just forget how. I'll let you know when I find how!

I found out that when installing, pip isn't installing the right thing, so I think that your publishing the package wrong. (I found this by looking at were pip installs packages)

Ah, okay. Well, if you look at the pypi page, it is published, so I'm not exactly sure...

It is, but it's not installing the right thing

Oh, my bad. So the publishing method is incorrect when using pip?

Probably yes.

Hmmm, didn't this happen for ReplAPI as well?

No, use the publish instructions here

Ooh, kk. Thanks! I'll try that and let you know what happens.

Uh, so I tried doing the steps, not sure if it made a difference yet, I'll check.

@darkdarcool, I updated and did the correct way, however, it made not difference. Is there a different way I could upload this to pypi that works?

Thanks!

Yay i think it works!

Oh, okay! Let me test it, and see if it works!

Hmm, @Isaiah08-D, that doesn't work either. Let me ask darkdarcool, or find a way myself.

Thanks for trying though!

@JBYT27 Are you sure it doesn't work for you? I tried it on my computer:
image

it looks like it downloaded right, it just didn't run the api right. It's a step foward. All you have to do now is fix the API code itself.

Yep. However, the API code does work, it just seems like it doesn't work on your specific code editor @Isaiah08-D?

I figured out the error. It means incorrect credentials. You need an actual git auth token

I assume this is still a problem, as the v1.0.2 wheel released to PyPI yesterday lacks any actual code. The fault is in this line in setup.py:

https://github.com/JBYT27/GitAPI/blob/1c3e0c7e9b946a996378130954eb2fd3a796397f/src/setup.py#L17

This is invalid. packages needs to be set to a list containing the name of the import package — in this case, packages=["git_api"] (or, to properly future-proof against subpackages added later, from setuptools import find_packages and then do packages=find_packages()).

Before uploading your next wheel, you should make sure you've built it properly by inspecting the contents. A wheel is just a zipfile with a funny extension, so any program for examining zipfiles — like zipinfo — should do.

Oh, @jwodder, thanks for letting us know!
So basically I need to add to the packages argument, "git_api"?

So would this be okay?
f70e123

@JBYT27 Yes, that should work.

Yup it should

Ok, thanks!

I will close this issue after I upload to PyPi, just letting you know :)

YES, IT WORKS!

Thanks so much! I'll close this issue now!

Nice