otosky / medium_stats

Command Line and Python tool for Scraping Your Medium Stats
GNU General Public License v3.0
20 stars 5 forks source link

doesn't seem to install via pip? #18

Closed LeonAdato closed 1 year ago

LeonAdato commented 1 year ago

I'm sure I'm just missing something. I'm fairly new to python.

I'm running pip install medium_stats (and also medium-stats) but when I run the sample script included in the readme.md (with my info) it errors with:

File "<directory path>/medium_stats.py", line 3, in <module> from medium_stats.scraper import StatGrabberUser
ModuleNotFoundError: No module named 'medium_stats.scraper'; 'medium_stats' is not a package

This is happening on 2 different systems where other python scripts are running fine.

otosky commented 1 year ago

hey @LeonAdato - I'm not experiencing any issues installing from pip in a fresh environment:

mkdir pip-test
cd pip-test
python -m venv venv
sh venv/bin/activate

pip list
#Package    Version
#---------- -------
#pip        21.2.4
#setuptools 58.1.0

pip install medium-stats
#Package            Version
#------------------ ---------
#certifi            2022.12.7
#charset-normalizer 3.1.0
#idna               3.4
#lxml               4.9.2
#medium-stats       2.2.0
#pip                21.2.4
#requests           2.28.2
#setuptools         58.1.0
#urllib3            1.26.15

It's kind of hard to diagnose environment issues, but in an effort to help could you:

LeonAdato commented 1 year ago

Thanks for the quick reply. Yeah, I have a feeling I need to learn how to venv, and then come back to this. I'm really old-school, and running this on an actual bare metal system. Stay tuned.

LeonAdato commented 1 year ago

OK, got venv working.

$ python3 -m venv venv
$ sh venv/bin/activate
(doesn't work)

$ source venv/bin/activate
(venv) $ pip list
Package    Version
---------- -------
pip        22.2
setuptools 59.6.0

(venv) $ pip install medium-stats
(install happens here)

(venv) $ pip list
Package            Version
------------------ ---------
certifi            2022.12.7
charset-normalizer 3.1.0
idna               3.4
lxml               4.9.2
medium-stats       2.2.0
pip                22.2
requests           2.28.2
setuptools         59.6.0
urllib3            1.26.15

(venv) $ python3 medium_stats.py 
Traceback (most recent call last):
  File "medium_stats.py", line 3, in <module>
    from medium_stats.scraper import StatGrabberUser
  File "medium_stats.py", line 3, in <module>
    from medium_stats.scraper import StatGrabberUser
ModuleNotFoundError: No module named 'medium_stats.scraper'; 'medium_stats' is not a package
otosky commented 1 year ago

I think you might be clobbering the namespace by naming your script medium_stats.py. Can you try renaming the example script something like example.py and let me know if that executes correctly?

LeonAdato commented 1 year ago

As my Papu (grandfather) would say, "shit fire to save matches" (listen, it sounded WAY cooler in Ladino) that did it! I can take things from here. Thank you for being so responsive!

otosky commented 1 year ago

No prob! Happy hacking!