[Python] How do I install and run a python script

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    This is the ultimate noob question for python - but I'm asking it because I simply cannot fine the answer anywhere on the internet.

    How do I install and run a python script?


    For example, say, this repo: https://github.com/TineKolenik/hoffman_reproduction


    I tried the following : pip3 install -r requirements.txt
    But then I get a page of errors which begins with :


    Successfully uninstalled numpy-1.22.4
    Running setup.py install for numpy ... error
    ERROR: Command errored out with exit status 1:
    command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c


    'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_n/dj0hlyp12xz_c2_9pjwgktt00000gn/T/pip-install-btfk24yw/numpy/setup.py'"'"'; file='"'"'/private/var/folders/_n/dj0hlyp12xz_c2_9pjwgktt00000gn/T/pip-install-btfk24yw/numpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/_n/dj0hlyp12xz_c2_9pjwgktt00000gn/T/pip-record-ffl_swjt/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/kris/Library/Python/3.9/include/python3.9/numpy cwd: /private/var/folders/_n/dj0hlyp12xz_c2_9pjwgktt00000gn/T/pip-install-btfk24yw/numpy/ Complete output (5277 lines): Running from numpy source directory.

    Note: if you need reliable uninstall behavior, then install
    with pip instead of using `setup.py install`:

    - `pip install .` (from a git repo or downloaded source
    release)​

    pip3 install . returns:


    Defaulting to user installation because normal site-packages is not writeable ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
    ​

    python3 main.py gives :


    Traceback (most recent call last): File "/Users/kris/Projects/hoffman_reproduction/main.py", line 3, in import matplotlib.pyplot as plt ModuleNotFoundError: No module named 'matplotlib'
    ​

    I've tried running python packages in the past and have never managed to get one to run.

    Please help me out with the basic commands I need to install and run this repo - or pick another python repo, if there is something wrong with this one.

    Continue reading...

Compartilhe esta Página