After installing Python and Visual Studio code as followed on this link:
https://www.youtube.com/watch?v=dNFgRUD2w68&lc=UgxjG9Bd_Uwm9duwpld4AaABAg
I can't see the reload button in the VS but there are two button; one is disable, and the other is uninstall. Do you know why I don't have reload button and how to resolve this issue?
You don't have to reload the page. Python is already installed.
Just close the current window near the "Extension: Python".
If for some reason VSCode still can't recognize python files, just close it and open it again.
After finishing your Python file in VS Code, save all changes, head to the terminal and enter the directory of the python file(A directory is where you've saved your file), and type python example_file.py.
Of course, you can change the name example_file.py to your actual file name.
Related
I, probably, have a weird question but it really annoys me. I have created Venv and installed some modules. When I click the module file to scroll it, VS code shows the location of module file in the side explorer. I guess this feature can be turned off in preferences; but, unfortunately, I cannot find it.
Add the following code to your setting.json:
"explorer.autoReveal": false
Then vscode will not open the floder when you open or click a tab or other things.
I am trying to use the Interactive window of VSCode, but it loads the wrong version of Python. I want it to load the version of the virtual environment (shown bottom left), but it defaults to something else.
I have tried this approach, but I can't simply click the version and change it because it isn't included in the drop down list. I have tried adjusting the settings.json file python.defaultInterpreterPath but that didn't work (perhaps my syntax is wrong). I have also made sure that jupyter is installed in the virtual environment.
I always run VSCode in the project folder from the command line using code . but strangely, something that has worked is running it using code (without the period). This is not a solution however, because the workspace folder is not updated, meaning that when I change the project I'm working on, VSCode opens in previous workspace.
You can try to delete all the files and folders under this location:
C:\Users\${UserName}\AppData\Roaming\Code\User\globalStorage
Others:
The python interpreter of the .ipynb file was stored in the database located at:
C:\Users\${UserName}\AppData\Roaming\Code\User\workspaceStorage
Such as:
If you open a new .ipynb file in the VSCode which name has not storaged in the database, you will need to select the interpreter.
It's different from the interactive. You can find, any time you reopen the VSCode, the last time you created interactive will be disappear.
(I'm currently learning Python so I might be missing something obvious - sorry if this is the case)
I'm using Visual Studio Code and the AREPL extension (to get an idea of what will show up while I'm writing code) to learn Python coding
However, I encountered a weird error, where different working directories seem to be registered for AREPL and the console (sorry I'm new so my descriptions and wording might be inaccurate)
Specifically, if I type
cwd = os.getcwd()
print(cwd)
on the AREPL panel, it shows the folder containing the python file I'm working on as the working directory (C:\Users\XXXXXX\Coding\Python),
but when I actually run the code, the console shows the upper folder (directory?) (C:\Users\XXXXXX\Coding )
So when when I try to open different files in the C:\Users\XXXXXX\Coding\Python folder using a relative path (e.g. open("temp.txt", "r")) then it runs without error on the AREPL window and displays the expected results, but shows an error when I actually run it through console
This is also weird because I remember having used relative paths in the past without problem when I was working on a file in a different folder
FYI, I never changed any settings related to working directory or manually set them until now
I know that the obvious easy answer is to use an absolute path, but I'm just trying to figure out what might be causing the error to better learn about Python (or Visual Studio Code)
Thank you!
The reason is that the precise locations of the startup paths displayed by default on the two terminals are different.
In the default terminal of VS Code, the startup path displayed by default is the currently opened project folder. When a file is executed, it will automatically go to this file and then return to the project folder. This is convenient when executing any file in the project in this terminal, VS Code can go to it without reopening this terminal.
The "AREPL" terminal executes this python file, and it displays the parent folder of the executed file by default. When we switch other executable files, the "AREPL" terminal needs us to reopen this terminal.
I'm trying to use the LeXtudio ReDtructuredText extension for Visual Studio Code. It's not working, and the reason is not clear.
After I installed the extension I tried to use it by clicking the "split screen" icon below the menu bar, and I got a popup message that said, "Please review Python installation on this machine before using this extension."
I clicked the "Learn more" link and learned that the extension depends on Python 3.5 or later. My system runs Python 2.7 because our production environment uses tools that depend on it, but I have Python 3.8 installed too. I followed a "learn more" suggestion and added python.pythonPath to the VS Code settings file. Then I tried again, and got the same message.
Did I modify the settings file right? I think so; here's how it looks so others can check. (Line 2 has been added.)
{
"python.pythonPath": "C:\\Program Files\\Python38\\",
"editor.minimap.enabled": false,
"breadcrumbs.enabled": true
}
Did I put the right value in the string? I think so; when I examine C:\Program Files\Python38\ in File Explorer I see that it's a Python installation's top level directory, and python.exe is in it.
Did I modify the right file? I did; when I changed "breadcrumbs.enabled" from true to false, the editor's breadcrumb display disappeared instantly -- I didn't even have to restart the editor.
Any ideas?
The extension instructions also recommend using Microsoft's Python extension to change the setting. It says that this "really makes configuring Python environment easier," although it doesn't explain how.
It says, "Once you have that Python extension installed, open conf.py in VSCode." It's not clear what this is for, since the settings file is named settings.json, but I hoped that when I opened the file that would become clear. But the instructions don't say where this file is, and I can't find it. I searched my user directory and both Program Files directories, and the only files I found with the name conf.py were in Sphinx projects... not a likely place to put VS Code settings.
Any ideas?
So, I am new to Python (programming generally), I did download Python 3.7, Visual Studio Code, Python, code runner extensions inside Visual Studio code and created python file and ran a code say (print ('me')), after that I make a change to the code say, print ('him') , it still runs 'me' not 'him' . I am not sure why. It works only if I open a new file and save it., but I dont wanna do that. I want to make changes on the existing python file not create a new one everytime.
I did follow installing instructions given by this user on Youtube. seems I got the installation right .
https://www.youtube.com/watch?v=saz6A20E9Mk
It seems like you did not actually save your changes. It is important to understand what is happening when you "edit" a file. Your file is "saved" on your computer's hard drive (somewhere). That is what is being run when you press run -- the saved file.
If you have your "old code", your (print ('me')), change that to (print ('hello world')) and navigate to File -> Save in Visual Studio Code. From there, try running that file from within VSCode. See what happens.
When you open it in VisualStudioCode, you are not actually editing that file that is saved on your hard drive! Your computer has placed a temporary copy of it in your computer's memory, which is what is being edited. Therefore, if you want to run your edited code, you need to Save the file you are editing. It is common practice to use keyboard shortcuts, like Commmand + S to do that easier.
If you are interested in enabling autosave, to avoid needing to manually save, you can find more details on how to do that at this visual studio documentation link