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?

slava
  • 791
  • 1
  • 11
  • 26
BBedit
  • 7,037
  • 7
  • 37
  • 50
  • Please post the contents of the `gfyc` directory and your `__init__.py` files. – sloppypasta Apr 10 '19 at 14:40
  • Is there any update on this question? I'm having the same problem. – Mushu909 Oct 13 '19 at 20:23
  • See the accepted answer to [this question](https://stackoverflow.com/questions/53778741/use-a-python-package-in-the-same-project-folder-in-visual-studio-code)
    https://stackoverflow.com/questions/53778741/use-a-python-package-in-the-same-project-folder-in-visual-studio-code
    – wale A Jun 09 '20 at 17:54

0 Answers0