pypa / packaging-problems

An issue tracker for the problems in packaging
151 stars 35 forks source link

Trouble with a packaging tutorial #689

Closed grandell1234 closed 1 year ago

grandell1234 commented 1 year ago

OS version

Unknown Virtual-Machine

Python version

3.11.5

Pip version

23.2.1

Guide link

https://packaging.python.org/en/latest/tutorials/packaging-projects/

Problem description

Issue: Python does not recognize my package as existing even though it shows when I do pip3 list Images: (MyFiles I left init blank as instructed) (error message) (package showing when I do pip3 list Screen Shot 2023-08-29 at 5 26 21 PM

Screen Shot 2023-08-29 at 5 34 38 PM Screen Shot 2023-08-29 at 5 26 46 PM

Error message

Traceback (most recent call last):
  File "/workspace/main.py", line 1, in <module>
    import ________ as ______
ModuleNotFoundError: No module named __________
merwok commented 1 year ago

Looks like a discrepancy between the python you run and the one that runs pip. Can you look at these commands:

$ which python3
$ which pip3
$ head $(which pip3)
$ python3 -m pip list
grandell1234 commented 1 year ago

Here you go:

@merwok

which python3: /usr/local/bin/python3

which pip3: /usr/local/bin/pip3

head $(which pip3):

!/usr/local/bin/python

-- coding: utf-8 --

import re import sys from pip._internal.cli.main import main if name == 'main': sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0]) sys.exit(main())

python3 -m pip list:

beautifulsoup4 4.12.2 bs4 0.0.1 certifi 2023.7.22 charset-normalizer 3.2.0 idna 3.4 numpy 1.25.2 pip 23.2.1 requests 2.31.0 scratchattach 1.3.6 scratchreturn 0.0.7 setuptools 65.5.1 soupsieve 2.4.1 urllib3 2.0.4 websocket-client 1.6.2 wheel 0.41.2 ➜ /workspace git:(master) pip3 list Package Version


beautifulsoup4 4.12.2 bs4 0.0.1 certifi 2023.7.22 charset-normalizer 3.2.0 idna 3.4 numpy 1.25.2 pip 23.2.1 requests 2.31.0 scratchattach 1.3.6 the one I created 0.0.7 setuptools 65.5.1 soupsieve 2.4.1 urllib3 2.0.4 websocket-client 1.6.2 wheel 0.41.2

merwok commented 1 year ago

It is strange that you have src with python files directly. I would expect src/importable_package_name/__init__.py etc.

Can you show the part of your packaging file (pyproject.toml or setup.cfg or other depending on your build backend) that configures the list of modules/packages in your project?

How did you install your project?

grandell1234 commented 1 year ago

It is strange that you have src with python files directly. I would expect src/importable_package_name/__init__.py etc.

Can you show the part of your packaging file (pyproject.toml or setup.cfg or other depending on your build backend) that configures the list of modules/packages in your project?

How did you install your project?

Thank you so much! I just needed to put the python files into a file so I could import the file.