Or modify sys.path adding the parent dir to it. So, add the parent dir to pythonpath, and it will work. That scripts in that directory will be loaded instead of modules of The PTVS 2.0 alpha is now live and available for installation. This update to the tools provides new IntelliSense and debugging features, and adds improved support for Windows Azure. Of the search path, ahead of the standard library path. Microsoft recently announced an update to the Python Tools for Visual Studio (PTVS) - PTVS 2.0 alpha. Theĭirectory containing the script being run is placed at the beginning Dont be fooled by the name - the book also covers ASP. PYTHONPATH (a list of directory names, with the same syntax as theĪfter initialization, Python programs can modify sys.path. Visual Studio 2013 Cookbook by Jeff Martin and Richard Banks is a great bridge to new users and experienced users alike to the features of Visual Studios latest release, 2013. The directory containing the input script (or the current directory). sys.path is initialized from these locations: If not found, it then searchesįor a file named spam.py in a list of directories given by the When a module named spam is imported, the interpreter first searchesįor a built-in module with that name.
Probably it is because the terminal runs under different environmental settings, where the python interpreter can find the parent directory and thus the foo.py: Check if Python Tools is enabled or not if the Python Tools are not enabled in Visual Studio 2015 Community, check Python Tools Step 2 Install an interpreter Python has different kinds of interpreters.
The real question is why it works in the terminal. I guess, this issue is not about Visual Studio and not about why it doesn't work in VS.