[Python] Tried many different things but cannot get python imports to work [Import "mrjob.job"...

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    As the title suggests. I tried so many different things to get python import to work but had no luck.

    VSCode Screenshot

    I am trying to run this code:

    #VSCode Screenshot
    from mrjob.job import MRJob
    import re
    import numpy as np # an older exercise required this

    class MRGrep(MRJob):

    def mapper(self, _, line):
    match = re.search(r"(_[\w]+_)", line)
    if match:
    yield (match.group(1), line)

    def reducer(self, word, lines):
    for current_line in lines:
    yield (word, current_line)

    if __name__ == '__main__':
    MRGrep.run()

    • I have tried uninstalling and reinstalling python.
    • I have nano ~/.zshrc and changing alias to the "/opt/homebrew/bin/python3"
    • I have changed the python interpreter to recommend, global (Python 3.13.1 and Python 3.13.3 after the reinstall)
    • Tried changing the code runner executor map
    • Tried creating a virutal environment (VS Code), pip install mrjob, and then running it but no luck. "which python" would return the homebrew python and I tried changing the interpreter to the .vnev python many times but which python would still return the opt/home/..

    I had exercise before that had issues with numpy not importing. I researched a solution and found a stackoverflow post but I still could not figure it out.

    Edit: I did "pip install numpy" and "pip install mrjob". The installation were successful but VSCode still gives an error and says it cannot be resolved. I have tried running my code through VSCode terminal with "python ..." and I have the code runner extension which I also tried, but no luck. I tried python 3.13.1 interpreter and 3.13.3 (homebrew/python).

    Frameworks >> Python versions

    Continue reading...

Compartilhe esta Página