I've been working on a script which imports data from other python scripts with the "from X.py import *" method. At the moment I am willing to compile all files to create a shortcut (basically same functionality outside of the Visual Studio code GUI), thus I had added all necessary files to the folder where the .exe file is located. I had hoped this would work, as python doesn't (as far as I know) allow for importation of .py files through different paths with the "from X.py import *" method, but in the end I was sad to find out this didn't work. Is there a way for me to still make the python data scripts accessible outside of Visual Code (basically making the code look for data through a different path), or is the only solution to my problem using a different importation/data saving & extraction method? Is there any type of "from file('C:\thing') import X.py" method?
You can import data from other python scripts by adding the path to the folder containing the python scripts to the sys.path list. Here is an example of how to do it:
import sys
sys.path.append('/path/to/folder')
from X import *
This will allow you to import the X.py module from the folder located at /path/to/folder. You can also use a relative path to the folder if it is located in the same directory as your script. For example, if your script and X.py are located in the same directory, you can use:
from . import X
This will import the X.py module from the same directory as your script.