Reputation: 53
I was trying to follow this video posted: https://www.youtube.com/watch?v=ySRQsrkrVCU
I setup a virtual environment following this video: https://www.youtube.com/watch?v=Wuuiga0wKdQ made the requrement.txt file here
now when I try to run my code I get an error saying Modulenotfound no module named 'yfinance' I am confused as to what the problem is for this, I also had a general question about virtual environment in VS code, every time I start a new project, will I have to go through the video and make new path or is there a terminal code I can run?
Upvotes: 2
Views: 431
Reputation: 1709
You have at least 2 different problems:
Edit: it may only be the 2 if the third image is a screenshot from your VS Code terminal and not an external cmd and assuming you are running your Python code within the editor tools.
If that's the case, check your launch.json
file in VS code. It should be something like this:
{
"version": "0.1.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"python": "<path to your virtualenv>/bin/python",
"program": "${fileBasename}",
}
]
}
Make sure your "python"
is pointing to the right python binary a.k.a. the one in your virtualenv path.
Then in VS code's general settings you can set "venvFolders"
as a list of paths where your virtual environments were defined.
{
...
"python.venvFolders:" ["<venv path 1>", "<venv path 2>"]
}
Check out the official guide: and another one related to the general settings.
Upvotes: 2
Reputation: 161
The reason for this issue may be because your application doesn't use the right Python interpreter or you haven't setup the PYTHONPATH for this application yet.
Trying saving this script as .bat file then put it under your source code then execute this .bat file. Then trying executing your application again.
@echo off
echo ---------SETUP PYTHON PATH---------
echo %cd%
setx PYTHONPATH %cd%
echo -----------------------------------------
pause
Upvotes: 0