Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all 98452 articles
Browse latest View live

Is there another step to importing Pytorch and using it?

$
0
0

I'm trying to test Pytorch but the first step is to get it running and usable on my computer. I have it to an extent but I need it to function in VS code which it does, it's just that it reads as an error despite working.

I've set up pytorch locally on my computer. I can run the test scripts fine in VS Code's integrated terminal.

Example 1

The issue comes up when I try to do some work normally in VS code.

from __future__ import print_function
import torch
x = torch.rand(5, 3) //This line has an error. torch.rand(5,3) is not callable)
print(x)

It says that module 'torch' has no 'rand' member. But it still outputs correctly. Running this in the terminal as a python file or in debug mode results in.

(base) c:\Users\Sean\Desktop\Test\hello>D:\Anaconda\python.exe c:\Users\Sean\.vscode\extensions\ms-python.python-2019.10.44104\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 63625 c:\Users\Sean\Desktop\Test\hello\something.py
tensor([[0.5449, 0.1669, 0.4740],
        [0.3079, 0.0447, 0.9543],
        [0.9137, 0.3987, 0.5736],
        [0.1788, 0.4932, 0.5584],
        [0.1632, 0.6285, 0.4483]])

(base) c:\Users\Sean\Desktop\Test\hello>D:/Anaconda/Scripts/activate

(base) c:\Users\Sean\Desktop\Test\hello>conda activate Anaconda
Could not find conda environment: Anaconda
You can list all discoverable environments with `conda info --envs`.

So it's working, what I want is to not have it coming up as an error. It'll be hard to find the actual bugs later on if it continues and I feel it might cause problems if not addressed. Any help with telling me the root issue and how to go about fixing it would be appreciated.


Add Custom python.pythonPath to List of Interpreters

$
0
0

I want to use a custom python interpreter, which you can do by adding to python.pythonPath, as seen in the image below. However, I thought that there would be an option so that I could add an interpreter to the list of available interpreters that you can see in the below, so that I can easily switch between them, without the need to go rooting around in my user/workspace/folder settings.

Is there any way to add to the list as opposed to using python.pythonPath to override what is currently shown in the bottom left?

enter image description here

fatal error: 'wchar.h' file not found #include_next . error with visual studio code

$
0
0

I keep getting errors in VSC on programs which work in my IDE Clion. I now tried building a simple program and it still causes errors. Using Mac.

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/wchar.h:119:15: fatal error: 

  'wchar.h' file not found
 #include_next <wchar.h>

 1 error generated.
 The terminal process terminated with exit code: 1

code hello.cpp

#include <iostream>

using namespace std;
int main()
{
    cout << "Please enter your name: ";
string name;
    cin >> name;
    cout << "Hello, "<< name;
    cout << "\n";
return 0;
}

This doesn't build. but the executable file hello works as intended. when I try to build with clang it throws this error. when I try to use the command g++ hello.cpp in terminal, it gives this error:

ld: can't write output file: a.out for architecture x86_64

clang:

error: linker command failed with exit code 1 (use -v to see invocation)

Dev Container is not starting in VSCode

$
0
0

Hi Guys I'm trying to open the dev container from https://github.com/microsoft/vscode-remote-try-cpp and I get an error message when creating it.

It is also saying that this command is failing:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe run -a STDOUT -a STDERR --mount type=bind,source=c:/Users/jnvie/vscode-remote-try-cpp,target=/workspaces/vscode-remote-try-cpp,consistency=cached -l vsch.quality=stable -l vsch.local.folder=c:\Users\jnvie\vscode-remote-try-cpp -l vsch.remote.devPort=0 -u vscode --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --entrypoint /bin/sh vsc-vscode-remote-try-cpp-a8dfd3c1511c138f783ff7d36d26f76c -c echo Container started ;  while sleep 1; do :; done

with this error message:

SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
Run: docker run -a STDOUT -a STDERR --mount type=bind,source=c:/Users/jnvie/vscode-remote-try-cpp,target=/workspaces/vscode-remote-try-cpp,consistency=cached -l vsch.quality=stable -l vsch.local.folder=c:\Users\jnvie\vscode-remote-try-cpp -l vsch.remote.devPort=0 -u vscode --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --entrypoint /bin/sh vsc-vscode-remote-try-cpp-a8dfd3c1511c138f783ff7d36d26f76c -c echo Container started ;  while sleep 1; do :; done
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Drive sharing failed for an unknown reason.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.

My system is running windows 10 pro and I previously had docker toolbox running before I upgraded and got docker desktop for windows

vscode typescript intellisense not working for evernote

$
0
0

I've installed https://www.npmjs.com/package/@types/evernote to my project to get evernote types definition.

When I import Evernote as follow

import { Evernote } from 'evernote';
const client = new Evernote.Client({
  consumerKey: '...',
  consumerSecret: '...',
  sandbox: true,
  token: '...'
});

Vscode recognize Evernote and suggests me autocompletion and lists all the available methods and objects. However, When I run my project, it says TypeError: Cannot read property 'Client' of undefined

When I import Evernote as below, I can run my app:

import * as Evernote from 'evernote';

But I don't get the autocompletion working.

How should I import my evernote module to make it works properly?

I've also tried

import Evernote = require('evernote');

but it doesn't work neither

VSCode nested snippets

$
0
0

I'm wondering if I can refer to another snippet within a snippet in VSCode user defined snippet.

Say I have

"Test1": {
        "prefix": "snippet_test1",
        "body": 
            "something"
}

and is there a way to insert snippet_test1 to another snippet like

"Test2": {
        "prefix": "snippet_test2",
        "body": 
            "${1:snippet_test1}"
}

Now snippet_test2 just output "snippet_test1" instead of the content of snippet_test1.

How to setup VS Code to not unfold automatically?

$
0
0

I try to keep my VS Code functions folded. But it looks like it auto unfolds every time I reopen the project. Is there a way to keep my functions folded?

Looking online, this issue occurs when you have prettier extension installed but I do not have that extension installed.

How to exclude files from "format on save" in VSCode?

$
0
0

Currently in VSCode settings you can configure format on save as following:

"editor.formatOnSave": true

I want to exclude some file extensions, for example only format JavaScript but not HTML files.


Am I understanding this VS Code API behavior correctly? Non-default *object* settings (when provided) are always merged?

$
0
0

I'm working on a VS Code Extension, and I think maybe I'm missing something in the docs, or else the behavior I'm seeing just isn't specified there, and my assumptions are wrong...?

I've defined some default settings for my extension, like so...

package.json

"contributes": {
    "configuration": {
      "title": "ToggleSettingsChanges",
      "properties": {
        "toggleSettingsChanges.settingsToToggle": {
          "scope": "resource",
          "type": "object",
          "default": {
            "window.zoomLevel": 2,
            "editor.fontSize": 22,
            "terminal.integrated.fontSize": 16,
            "scm.diffDecorations": "none",
            "workbench.statusBar.visible": false,
            "editor.cursorBlinking": "solid",
            "workbench.activityBar.visible": false
          },
          "description": "[ snip ]"
        }
      }
    }
  },

extension.js

// In the "main" method that runs when a command is activated:

const config = vscode.workspace.getConfiguration("toggleSettingsChanges");
const settingsToToggle = config.get("settingsToToggle");
const inspectedSettingsToToggle = config.inspect("settingsToToggle");

console.log("settingsToToggle:", JSON.stringify(settingsToToggle), "\n\n")
console.log("inspected settingsToToggle:", JSON.stringify(inspectedSettingsToToggle), "\n\n")
return;

In the Extension Host instance, I can tweak and adjust the settings, to include this:

User or Workspace Settings JSON

// ... 
"toggleSettingsChanges.settingsToToggle": {
  "editor.fontSize": 11,
  "pumpkins_are_great": true
},

In the console output, I'm seeing the following:

settingsToToggle: {"window.zoomLevel":2,"editor.fontSize":11,"terminal.integrated.fontSize":16,"scm.diffDecorations":"none","workbench.statusBar.visible":false,"editor.cursorBlinking":"solid","workbench.activityBar.visible":false,"pumpkins_are_great":true} 

inspected settingsToToggle: {"key":"toggleSettingsChanges.settingsToToggle","defaultValue":{"window.zoomLevel":2,"editor.fontSize":22,"terminal.integrated.fontSize":16,"scm.diffDecorations":"none","workbench.statusBar.visible":false,"editor.cursorBlinking":"solid","workbench.activityBar.visible":false},"globalValue":{"editor.fontSize":11,"pumpkins_are_great":true}} 

For the settingsToToggle line, I expected to see only the following settings:

{"editor.fontSize":11,"pumpkins_are_great":true}

It seems that if you provide an object default, any configuration provided is merged with that object, instead of replacing it entirely.

Is that the case? Have I missed this in the documentation?

It seems to me that a value (even an object) would be overwritten, and not simply merged.

How to integrate exist project with jsconfig

$
0
0

I was about to integrate jsconfig.json with my existing project for benefitting from its baseurl option.As the template showed by vs-code,I added a jsconfig.json to my client folder(which has its own node_modules, completely separated from server).But seems like it doesn't work.Meanwhile, it shows an error at the beginning of the jsconfig file client/node_modules/harmony-reflect/index' not found, but when I yarn add harmony-reflect to client modules,the error still exists.Here is the code:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "components/*": ["./src/js/components/*"]
    },
    "module": "es6",
    "target": "es2020"
  },
  "exclude": ["node_modules"]
}

Could you guys help me with this?Thanks!

How to switch text case in visual studio code

$
0
0

How does one switch the case of highlighted text in Visual Studio Code? VS allows this via CTRL+SHIFT+U and CTRL+U.

Is there a command binding that I can set up to do this, or is it by default some other key combination?

How to change VisualStudioCode comment color with it's slashes?

$
0
0

I added this code to my setting.json

"editor.tokenColorCustomizations": {
    "comments": "#00ff00"
}

But It doesn't change the color for slashes as you can see the below screenshot.
It remains still grayed.

How can I change the whole comment color contains slashes?

enter image description here

Change color of characters surrounding comments in VS Code

Vs code blank terminal problem, can't enter anything

$
0
0

I'm user using Visual Studio code. A few days ago, I've gone through some problems. It's about "blank terminal". I'm not sure what trigger this problem. I guess it's related with vs code updated 1.39 version. I attached the picture below.

enter image description here I've tried searching solution in order to solve this problem. but I failed. 1. remove the 1.39 version. and re install vscode. (remove vscode file) - sudo apt remove vscode, sudo apt autoremove - I searched .vscode and then remove all( some setting file left.) 2. I tried to install vscode by snap, but result was same. 3. I started with root - sudo code --user-data-dir => teminal is possible to see but environments not working => fail 4. I tried down grade. - version 38,37 => failed (it's same result) - version 32 => success (but it's old version, limited several utilities)

**Ubuntu 18.04.3 LTS , 64 bit Anyone having same problems and working out, Please tell some methods. I look forward to getting reply. Thanks.

how to have vs code's typescript extension apply to files with non-typescript file extensions

$
0
0

I was wondering how I can use the built-in typescript extension apply to files with file extension .foo as if they were .tsx


How to write automated tests for VS Code themes

$
0
0

I'm developing a VS Code theme and I would like to setup some form of automated tests to prevent unindented regressions when making updates to the theme. I have developed another theme in the past and this was by far the most difficult part of it as changing one or two scopes can have unintended side effects in other languages.

Has anyone else wrote some form of automated tests for VS Code themes that would have some advice on how to do this. Thanks!

Visual Studio Code can't be opened because "Apple cannot check it for malicious software"

$
0
0

I have downloaded Visual Studio Code for the first time but I keep getting message below:

apple error message when clicking on VSC app

"Visual Studio Code" can't be opened because Apple cannot check it for malicious software.

This software needs to be updated. Contact the developer for more information.

My MacBook is up to date, and I even updated the latest version of VSC on their website (September 2019 (version 1.39); there is none for October) but it still gave me the same message.

Looking into their FAQ, I read about reinstalling VS Code. I did that but it still doesn't work.

CondaHTTPError in VSCode - Failure in installing Linter

$
0
0

Unable to install linter in VSCode and in turn run any Python code

I have tried installing openssl. I have tried it with multiple different GitHub project repos. I have also tried it with Pycharm. It works fine in Pycharm

PS C:\Users\xxx\my_project\my_project>& C:/Users/xxx/Documents/Anaconda/Scripts/conda.exe install --name myenv pylint Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json Elapsed: -

An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file a support request with your network engineering team.

SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))

I expect VSCode to be able to install the linter and allow me to run the code just like Pycharm is

Visual Studio Code debugger with Chrome refused to connect to localhost

$
0
0

I've tried several suggestions on other posts to no avail.

I have a 9 month old project that no longer shows in the browser from F5 debugging in vs code.

I set up a brand new simple project with an index.html file to try to get Visual Studio code to launch it in a Chrome browser window.

I keep getting an error page in chrome that says:

This site can’t be reached localhost refused to connect. Did you mean http://localhost8000.com/? Search Google for localhost 8000 ERR_CONNECTION_REFUSED

launch.json:

    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8000",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

index.html:

hello world!!!!!

Any help would be greatly appreciated!

What is causing VS Code to scan every PHP file in a workspace?

$
0
0

When opening any PHP-based workspace in Visual Studio Code, I'm getting EMFILE: too many open files errors for every PHP file in the included directories. This happens right as the window loads the workspace, and happens with extensions enabled and when they're turned off (via Developer: Reload with Extensions Disabled).

Example output line:

[2019-10-26 07:13:58.364] [renderer1] [error] EMFILE: too many open files, open '/path/to/workspace/app/vendor/psy/psysh/test/CodeCleaner/InstanceOfPassTest.php': Error: EMFILE: too many open files, open '/home/curtis/code/matchthememory.cake3/app/vendor/psy/psysh/test/CodeCleaner/InstanceOfPassTest.php'

This prevents all of the extensions and even some core functionality from working, so I can't see a file outline or check changed files in "Source Control", for example. It also makes my CPU spike, with several different code processes running while attempting to load the workspace.

In my local filesystem (Linux Mint, if that matters), I've tried increasing my open file limit (ulimit -n 20000), but that didn't help. Even if it did, I think that would be just working around the true problem: something's attempting to access every file.

My questions are:

  1. What is causing these file scans?
  2. Can I prevent them from happening at all?
  3. Can I prevent them from happening for specific files in my workspace, e.g. external "vendor" files that I don't control? (i.e. only allow the scans for my files)
Viewing all 98452 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>