Getting ModuleNotFoundError in python, package exists in virtual environment though - visual-studio-code

I am new to python and writing my first python file using Visual Studio Code. Till yesterday the code was working fine. But today it is starting to give ModuleNotFoundError. I double-checked the package and the package is there under lib folder of the virtual environment. Moreover, IntelliSense is also working fine, whenever I write import it shows the requests module in the available list. I am facing problems with IntelliSense also, as sometimes it stops working for no reason.
The major change that I did before executing the code is the integration of GitLab with my project.
Python Version: 3.6.2
Operating System: Windows
Git Version: 2.23.0
Pylint Version: 2.3.1
pip Version: 19.2.2
Requests Version: 2.22.0
Pytest Version: 5.1.1
Enabled Extensions:
Npm
Npm Intellisense
Ayu
Code Runner
AYU
Markdownlint
Predawn Themekit
Python by Microsoft
Can anyone have gone through with the same problem? Please help me to resolve this issue.
Attachments

Issue resolved I was running it using Ctrl+Alt+N (code-runner shortcut to run a project)which was creating this issue. But running the file in terminal using Run Python File in Terminal (option in the context menu when we do right-click in source .py file) giving me the expected result without any error.
Then I googled for how to alter this behavior so that I can get the same results by using Ctrl+Alt+N as well.
I found that; I need to add the following script under user's settings.json.
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
Here is my complete user's settings.json
{
"workbench.colorTheme": "Predawn",
"workbench.iconTheme": "ayu",
"window.zoomLevel": 0,
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
}

Related

Adding pep8-naming to VSCode

I am trying to get PEP8-naming working on my VSCode (Version: 1.72.2 (Universal)) without luck.
I have flake8, isort and mypy enabled in my code and this all works as expected. I have installed pep8-naming (conda install -c conda-forge pep8-naming) and it shows in my flake8 version info:
flake8 --version
4.0.1 (mccabe: 0.7.0, naming: 0.13.2, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.8.13 on Darwin
However, I am not seeing the errors for naming conventions showing in my VSCode editor.
I have the following set in my settings.json file
{
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.pycodestyleEnabled": true,
"python.linting.pycodestyleArgs": ["--max-line-length=120"]
}
What am I missing so as to be able to see (for instance) that variables are named in Camel case rather than lower case with underscores?
I have tried this without any luck.

How can I fix the attribute error in VS code when the same code runs perfectly on colab?

I was running the PySINDy package and I kept on getting the module not found-error when I ran this:
pip install pysindy
import pysindy as ps
I fixed this by downgrading the Python in my VS code to 3.8.9. But I do get the following note:
note: This error originates from a subprocess, and is likely not a problem with pip.Note: you may need to restart the kernel to use updated packages.
I am now getting the attribute error when I run the following:
differentiation_method = ps.FiniteDifference(order=2)
Here's the error:
AttributeError: module 'pysindy' has no attribute 'differentiation'
Can someone please help me with this? (I successfully ran the entire code earlier on google colab and the online Jupyter, but I am unable to do it locally. I use MAC os and Jupyter via VS Code.)

Cargo build broke after using VS code

For a while I have been editing my Rust program with Pycharm Professional. However, I was curious and experimented with VS Code. At first my project was compiling and running. However, it suddenly started throwing a pretty wild error on cargo build and cargo run (while cargo check is fine), even in cmd outside of VS Code:
error: linking with `link.exe` failed: exit code: 1104
= note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\rust\\book\\target\\debug\\deps\\book.1apvyby1qhuehv3.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1cw7xmk0cjjg5uln.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1e8ho0j4rykowhcr.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1g2fbveo2gp7bxds.rcgu.o"
..............
..............
= note: LINK : fatal error LNK1104: cannot open file 'C:\rust\book\target\debug\deps\book.exe'
book is the name of my project.
I am on Windows 10, System Type: x64-based PC.
VS Code version 1.63.2
Sometimes VSCode file watcher watches the files in target/, that is not good.
So open the Settings, search for exclude, and in all "list-like" cofigurations add **/target/**, do a cargo clean and restart VSCode. This should fix this and future problems
Had to remove the directory, and redownload the whole project(used Git).

Cypress / Visual Studio Code / Cypress failed to start

I am junior QA Tester, started working with Cypress and IDE Visual Studio, after updating Cypress 5.2.0, I got a strange error like the following:
It looks like this is your first time using Cypress: 5.2.0
✖ Verifying Cypress can run /Users/viktoriiahanke/Library/Caches/Cypress/5.2.0/Cypress.app
→ Cypress Version: 5.2.0
Cypress failed to start.
This is usually caused by a missing library or dependency.
The error below should indicate which dependency is missing.
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Command was killed with SIGKILL (Forced termination): /Users/viktoriiahanke/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/MacOS/Cypress --no-sandbox --smoke-test --ping=563
----------
Platform: darwin (19.6.0)
Cypress Version: 5.2.0
I have already tried to delete Cypress and install it with npm from the beginning, but Cypress itself is working, when I download it manually , but when I try to start it in console or in Visual Studio Console it is not opening, writing me that I miss dependencies like above.
Did anyone have such problem before?
Run this command in the terminal export NODE_TLS_REJECT_UNAUTHORIZED=0
and then try installing again.
I think it had been updated from a previous version, 3.1.3. Go into cache and delete all versions of cypress then re-install.
Maybe that there are missing some vital folders/files like integration, cypress.json... Try to run the 'npm install' command in the terminal for installing the dependencies.
Also, maybe if you start from an existing project, it will be fine (run npm install command also).

New VSCode extension can't find vscode

Why does a new VSCode extension created with yeoman generator immediately not find vscode when starting debug?
Clean install of node, yeoman, and generator "code".
While I can continue to debug with this error, why isn't vscode found? Is it extraneous if debugging actually works?
Type Ctrl+` to get the console and then npm i whereupon you will get a message similar to this
Detected VS Code engine version: ^1.31.0 Found minimal version that
qualifies engine range: 1.31.0 Fetching vscode.d.ts from:
https://raw.githubusercontent.com/Microsoft/vscode/7c66f58312b48ed8ca4e387ebd9ffe9605332caa/src/vs/vscode.d.ts
vscode.d.ts successfully installed!
After that things should be hunky dory.