2

Directory structure:

Directory structure

pwd
/Users/Mobile Documents/Pythonista3/Documents

I cannot import from my workspace: (Documents/gfyc/gfyc.py folder)

#! python3
from gfyc import gfyc

pass

Output:

Traceback (most recent call last):
  File "/Users/Pythonista3/Documents/youtube_mirror/youtube_mirror_bot.py", line 3, in <module>
    from gfyc import gfyc
ModuleNotFoundError: No module named 'gfyc'

Visual studio code launch.json:

   "version": "0.2.0",
    "configurations": [

    {
        "name": "Python: Current File (External Terminal)",
        "type": "python",
        "request": "launch",
        "program": "${file}",

        # I have added the env line below
        "env" : {"PYTHONPATH": "${workspaceFolder}"},
        "console": "externalTerminal",

    }
]

Listing:

[/Users/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents]ls

Output:

__init__.py __pycache__  gfyc gym_helper.py  top_stories youtube_mirror

How can I import files from my workspace in Visual Studio Code?

3
  • Please post the contents of the gfyc directory and your __init__.py files. Commented Apr 10, 2019 at 14:40
  • Is there any update on this question? I'm having the same problem. Commented Oct 13, 2019 at 20:23
  • See the accepted answer to this question <br> stackoverflow.com/questions/53778741/… Commented Jun 9, 2020 at 17:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.