Closed Biber76 closed 1 year ago
These are the specs of my laptop where it works:
Version: 1.81.0 (user setup) Commit: 6445d93c81ebe42c4cbd7a60712e0b17d9463e97 Date: 2023-08-02T12:37:13.485Z Electron: 22.3.18 ElectronBuildId: 22689846 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.22621
Disabling all extensions doens't change the outcome
@Biber76 This usually means that the python environment that is selected to the python file is different from the one that is being used with the interactive window. If you look at Output > Python it will tell you which python environment was used to run the file.
The Output shows the correct venv for the interactive window which makes sense as the script runs without an issue. If I run the "run Python file" I don't get an output message at all. But in the lower right corner is shows me the same path which I think vscode uses for the "run Python file". Or can you tell me how to check which venv the "run Python file" uses? I have the python environment extension. I activated the correct venv for the workspace again. But I still have the same issue.
It is also weird that vscode automatically deletes the file after it hasn't been executed properly
Here's how you can access the logs, which should highlight the currentlty selected interpreter. Also let us know which kernel you are currently using.
Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
``` XXX ```
2023-08-07 21:57:41.206 [info] Starting Pylance language server. 2023-08-07 22:04:58.539 [info] Send text to terminal: source C:/venv/Investing/Scripts/activate 2023-08-07 22:04:59.051 [info] Send text to terminal: C:/venv/Investing/Scripts/python.exe c:/Python/Projects/Investing/test_download.py 2023-08-07 22:05:19.138 [info] Discover tests for workspace name: Investing - uri: c:\Python\Projects\Investing\test_download.py 2023-08-07 22:06:00.882 [info] Discover tests for workspace name: Investing - uri: c:\Python\Projects\Investing\test_download.py 2023-08-07 22:15:28.816 [info] Discover tests for workspace name: Investing - uri: c:\Python\Projects\Investing\test_download.py 2023-08-07 22:16:13.882 [info] > c:/venv/Investing/Scripts/activate.bat && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python "c:/Users/Martin Biber/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/printEnvVariables.py" 2023-08-07 22:16:13.882 [info] shell: commandPrompt 2023-08-07 22:16:14.103 [info] > c:/venv/Investing/Scripts/activate.bat && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python "c:/Users/Martin Biber/.vscode/extensions/ms-python.python-2023.14.0/pythonFiles/printEnvVariables.py" 2023-08-07 22:16:14.103 [info] shell: commandPrompt 2023-08-07 22:16:27.021 [info] Send text to terminal: C:/venv/Investing/Scripts/python.exe c:/Python/Projects/Investing/test_download.py 2023-08-07 22:16:45.162 [info] Discover tests for workspace name: Investing - uri: c:\Python\Projects\Investing\test_download.py 2023-08-07 22:19:23.456 [info] Discover tests for workspace name: Investing - uri: c:\Python\Projects\Investing\test_downloader.py 2023-08-07 22:19:26.575 [info] Discover tests for workspace name: Investing - uri: c:\Python\Projects\Investing\test_downloader.py 2023-08-07 22:23:35.655 [info] Send text to terminal: source C:/venv/Investing/Scripts/activate 2023-08-07 22:23:36.169 [info] Send text to terminal: C:/venv/Investing/Scripts/python.exe c:/Python/Projects/Investing/test_downloader.py 2023-08-07 22:23:55.527 [info] Discover tests for workspace name: Investing - uri: c:\Python\Projects\Investing\test_downloader.py
This is the venv I'm using: C:/venv/Investing/Scripts/activate
Is that the information you were looking for or do I need to send something else?
Also let us know which kernel you are currently using.
Is that also the kernel you are using? Click top right in interactive window, a screenshot would greatly help:
first image is the info in the lower right corner. I guess that is the workspace kernel. second image is the picture from the interactive window
Thanks, can you please try to run that script outside of VS Code in the terminal using the kernel on the top right? This is to double check whether the problem is in VSCode or a general issue with the script.
Click the kernel on the top right in the screenshot you sent to see the full path of what is currently selected.
This probably means that it is an issue in yfinance, right?
I created a venv with 3.10. That works. Maybe yfinance has an issue with 3.11. It doesn't explain why it works on my laptop but at least it works
Yep, issue seems with Python install or something funky in the system. Unfortunately as the issue does not seem to be related to Python extension itself, closing this. I encourage you to ask it on stack overflow in case you find out you're still blocked on it.
Does this issue occur when all extensions are disabled?: Yes/No
The following script runs in "run current file in interactive window" without an error. If I use the same script and choose "run Python file", it prints "start" "ticker is aapl" and then it takes some time and exits without downloading or saving or printing the rest of the script. It also doesn't give any error message.
It works on my laptop (also vscode but windows 11) but not on my PC with the specs above
Steps to Reproduce:
print('start') ticker = "AAPL" print('ticker is AAPL') df = yf.download(ticker, period="max") print(df.head()) print('middle') df.to_csv(f"./Data/{ticker}.csv") print('end')