iamkubi / pydactyl

Python wrapper for the Pterodactyl Panel API
MIT License
69 stars 21 forks source link

Question about pip package #7

Closed realkarmakun closed 4 years ago

realkarmakun commented 4 years ago

Hello, I'm fairly new to Python and I think my question in really stupid but I hope you can help me. In README.md it is advised to install pydactyl package using pip install py-dactyl but in examples package referenced as 'pydactyl'. More to that, after installing py-dactyl, VSCode do not recognize pydactyl module in from ... import ... line. I guess this is just my lack of Python knowledge but it is still confuses me.

iamkubi commented 4 years ago

What version of Python are you using?

The namespace in Python is totally separate from the namespace in pip. Unfortunately I had written most of the code and pushed it to Github before I checked Pip only to find out that pydactyl was taken by a piano tool and used py-dactyl for Pip instead.

The packaging manager doesn't really have much say in how the imports work, however depending on your Python version and maybe IDE they may be identifying the package based on the directory name and not the contents of that directory.

What do you get if you run: python -c 'import pydactyl ; print(pydactyl.__file__)'

Presumably that won't work given your experience in VSCode, so maybe also try python -c 'import py-dactyl ; print(py-dactyl.__file__)'

realkarmakun commented 4 years ago

Sorry for not answering, I got really busy and didn't have much time lately. I'm using Python 3.8.3 Also I'm on Windows so I couldn't make your commands run in command prompt but I got it to work in script like this:

import pydactyl
print(pydactyl.__file__)

So, when I was trying to run script with py-dactyl I got following message (don't mind filename :) ):

  File "backup.py", line 3
    import py-dactyl
             ^
SyntaxError: invalid syntax

And when I did just pydactyl I got this:

C:\Users\%username%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pydactyl\__init__.py

Also just in case my pip list output

Package   Version
--------- ----------
certifi   2020.4.5.1
chardet   3.0.4
decorator 4.4.2
idna      2.9
networkx  2.4
pip       20.1.1
py-dactyl 0.1.9
PyMySQL   0.9.3
requests  2.23.0
TatSu     5.5.0
urllib3   1.25.9
iamkubi commented 4 years ago

Hmm, well that definitely sounds like a problem with VSCode's code completion and not really anything to do with the library. Python searches site-packages for installed libraries, and we can see in your filename that it's properly named pydactyl there: Python38\site-packages\pydactyl\__init__.py

So although the pip package is named py-dactyl the library still exists in the pydactyl directory which is how Python sees it. That's why the examples use pydactyl, and I wouldn't expect py-dactyl to ever work inside of your Python code.

I don't think there's anything wrong here, but let me know if you still have questions.