[Python] Still can't find module after importing local library to virtual enviorement

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    I set up a virtual environment and pip installed a local library "dnd24" (its a very bare bones library I created). However, when I try to run a python script with python3 path/script.py in the terminal, it tells me that there's No module named 'dnd24'. When I run python3 -m pip list "dnd24" does show up.

    I try the same process of installing numpy and including import numpy in my code and everything works fine.

    I've tried changing the setup.py file (which is very minimal for my uses) and using different ways to pip install (pip install vs python3 -m pip install) but nothing so far has worked.

    edit:
    Here is the output of python3 -m pip show dnd24:

    Name: dnd24
    Version: 0.1
    Summary:
    Home-page:
    Author:
    Author-email:
    License:
    Location: /mnt/c/Users/pedro/Desktop/DND_Stuff/projects/.venv_projects/lib/python3.12/site-packages
    Editable project location: /mnt/c/Users/pedro/Desktop/DND_Stuff/src/dnd24
    Requires:
    Required-by:


    And here is the output of python3 -c "import sys; print(sys.path)":

    ['', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/mnt/c/Users/pedro/Desktop/DND_Stuff/projects/.venv_projects/lib/python3.12/site-packages']


    And here is my setup.py file:

    from setuptools import setup, find_packages

    setup(
    name="dnd24",
    version="0.1",
    packages=find_packages(),
    )

    Continue reading...

Compartilhe esta Página