Julia packages not found in vs code - visual-studio-code

I'm very new to vscode and have been using previously jupyter notebooks. The problem is that when I try to run julia in vs code, it doesn't find any of the packages that have been installed with jupyter. Do I have to reinstall everything or is there some way to fix this?
The julia code works, but not the packages.

Related

How to resolve Pylance "import could not be resolved" in VSCode Jupyter Notebook?

I am trying to import function query_creative inside of file query_creative.py into the notebook Notebook.ipynb. The file hierarchy is like this:
├───playground
│ Notebook.ipynb
├───src
├───queries
query_creative.py
The code I use in my notebook goes like this:
import sys
sys.path.append('..')
from src.query.query_creative import query_creative
and the thing works. However, the line with the function import is underlined by Pylance with the message: "Import could not be resolved" and when I use this function later on, it works but Pylance underlines it again. I've tried modifying the setting.json, but nothing seems to work. I thank in advance for any help!
I managed to solve it eventually by downgrading Jupyter extension to VS Code to v2022.4.1001071005. Thanks everyone for help!
Which version of vs code you have? I faced with same issue after updating to 1.70.
UPD.
Downgrading to 1.69.2 fixed that issue. However, I have another laptop with 1.70 with exact same notebook there is no such issue, so if you want to stick around 1.70 it is worth to try to completely remove vscode and install it again.
UPD2.
After a while my downgrade didn't help on another machine, so I compared Pylance output difference between them and find out, that "working" instance used legacy jupyter notebook support, while "buggy" with "LSP". After disabling option Pylance Lsp Notebooks Enabled everything worked as usual and fixed that problem
It seems that pylance is unable to determine that the code is importable. Instead of modifying your path at the beginning of the script, you could create a Python package with your code, then do:
cd your-project
pip install -e .
You can see a guide to create packages here.
With these settings, pylance and any other editor/IDE will be able to identify your project correctly.
Beware that in VSCode, you can switch the interpreter, so ensure you select one where your code is installed:
https://blog.csdn.net/qq_41019681/article/details/111193080
"python.analysis.extraPaths": [
"D:\\ProgramFiles\\Anaconda3-2021.05\\lib\\site-packages"
]
add "python.analysis.extraPaths" by
import package_name as pkg
print(pkg.__file__)

Pytorch module not found in VSCode

For the life of me I can't get the VSCode integrated terminal to correctly run a simple program that just has import torch in it. I've tried it all. I tried just installing pytorch via conda (I have Anaconda) inside the VSCode terminal, and then running my program inside the VSCode terminal as well. I tried creating a conda virtual environment, activating it, installing pytorch in it, and then running my program using the virtual environment. I tried switching the VSCode python to ('base': conda) and it didn't work. I tried switching the VSCode python to ('pytorch': conda) (I read this somewhere on StackOverflow), but I didn't find this. I tried uninstalling and re-installing the Python extension in VSCode. I tried just running python3 inside the VSCode terminal and seeing if >>> import torch would run, but it doesn't. I tried installing torch with pip or pip3 instead of with conda but it doesn't work, it just tells me that No matching distribution found for torch.
However, outside of VSCode, I can do import torch and it runs correctly. How could I solve this? I would very much prefer to use VSCode and its integrated terminal, but VSCode can't find pytorch for the life of me.
EDIT: Using MacOS Monterey and most updated python extension in VSCode

How I should open .ipynb as new notebook version in vs code

I reinstalled my vs code, then, when I open the .ipynb in vscode, I also reinstalled the jupyter plugin. But I found the old notebook version opened.
Before I reinstalled these programs, they were still new versions.
I suggest using Anaconda Navigator to download & use a virtual environment that could be easier to use in most cases.To use the virtual environment use -
Ctrl+Shift+P or Python: Select Interpreter command from the Command Palette.However,please make sure to add environment variables to your VS-Code.
Otherwise,best bet may be to use the Jupyter notebook from Anaconda Navigator which pretty much does the same thing

VSCode Jupyter Extension: Can't find new kernel after updating Julia?

I'm using the new Jupyter extension for VSCode insiders, and it worked great until I updated Julia (from 1.5.1 to 1.5.3). VScode will run plain .jl files without issue and correctly locates Julia 1.5.3, but the "Jupyter" extension hasn't located the new kernel and tries to use 1.5.1 (now deleted), so I can't run any .ipynb files.
How do I teach Jupyter where the new kernel is?
EDIT: My workaround has been to make a copy of the folder containing "Julia 1.5.3" and rename it "Julia 1.5.1" to make the old path work. This works, but I'd obviously prefer to update the path to the kernel.
When you switch kernels, you need to make sure you have "IJulia.jl" installed in the new Julia environment. See here for more details: https://github.com/JuliaLang/IJulia.jl#quick-start

Rust autocompletion not shown for items from the standard library

I can't get working autocompletion on VS Code on Ubuntu 16.04.
I've installed rustup from https://www.rustup.rs/ and installed the "rust-lang.rust" package. This extension installed rustfmt and tried to use both stable and nightly toolchains.
If I type std:: no suggestions are shown. Suggestions show on local mod import but not with the standard library. I tried to reinstall by removing via uninstall.sh and manually removing ~/.multirust and ~/.cargo and then installed again, but nothing changed.
What did I do wrong?
I didn't have the RUST_SRC_PATH variable set. In my VS Code settings, I added
"rust.rustLangSrcPath": "/home/ilya/.rustup/toolchains/**your_toolchain**/lib/rustlib/src/rust/src/"
and it did the job. This option comes from the kalitaalexey.vscode-rust package.