Tag Archives: vscode

Create xxx.vue file with vscode, add comments and report error

Create xxx.vue file with vscode, add comments and report error

Create a. Vue file

When we use vscode to create. Vue files, we need to install relevant plug-ins that support Vue, such as vetur

    after installing the plug-in,
    there will be an error in adding comments. This should be due to some conflict in the installed plug-in. To solve the error in adding comments, you can add a div tag to the template tag, that is

The vscode installation plug-in liveserver specified browser reported an error and could not be found

Problem Description:

After installing vscode, you do not want to use the default IE browser. You want to specify chrome or Firefox, but install the plug-in lever server or other browser plug-ins. When specifying the default browser, windows reports an error and cannot find chrome or Firefox
after reading many posted on the Internet, they are configured in settings.json. After personal practice, they have no effect. Later, after their own exploration, they found that the plug-in can’t find your chrome or Firefox. It’s not that you haven’t installed it on your computer, let alone on disk C; But because when a plug-in such as lever server specifies a browser, the windows system will find the installation directory of the software according to the system variables.

terms of settlement:

1. Open the control panel of the computer – & gt; System and security —– & gt; System
2. Open advanced system settings, click environment variables, system variables, and add a new variable named path: D: \ Kiki \ Mozilla Firefox
this directory is the directory where your Google or Firefox exe files are located
3. After configuring environment variables and saving, restart vscode

Vscode development Vue project eslint check error

When using vscode to develop Vue projects and eslint to check rules, V-for reports an error: expected ‘v-bind: key’ directives to use the viruses which are defined by the ‘V-for’ directive.
solution: define the index in the variable defined in V-for
example:

<div v-for="titile in titles" :key="title.index">{{ name }}</div>

[Solved] Error when vscode activates Python virtual environment

After executing Python – M venv myvenv to create a python virtual environment, the following error is reported when executing the script

The file D:\Tools\Python37\Scripts\Activate.ps1 could not be loaded, because running scripts is disabled on this system.

The reason is that windows prohibits unsigned scripts from running. You can solve this problem by executing the command set executionpolicy remotesigned in PowerShell.

VsCode+Anaconda+jupyter Error: Kernel died with exit code

The problem is solved later!!!!

Installation
vscade and Anaconda are installed on their own in Baidu. Python plug-ins are installed in vscade. The file operation of creating . Ipynb suffix is similar to the web version of Jupiter notebook
Error content:

Kernel died with exit code 1. D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\traitlets\traitlets.py:2196: FutureWarning: Supporting extra quotes around Unicode is deprecated in traitlets 5.0. Use 'hmac-sha256' instead of '"hmac-sha256"' – or use CUnicode. warn( D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\traitlets\traitlets.py:2151: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '70f91ecb-d1b9-4e6f-bab4-f4eb00d14e8c' instead of 'b"70f91ecb-d1b9-4e6f-bab4-f4eb00d14e8c"'. warn( Traceback (most recent call last): File "D:\IDE\Anaconda3\envs\pytorch\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\IDE\Anaconda3\envs\pytorch\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\ipykernel_launcher.py", line 16, in <module> app.launch_new_instance() File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance app.initialize(argv) File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\traitlets\config\application.py", line 87, in inner return method(app, *args, **kwargs) File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\ipykernel\kernelapp.py", line 570, in initialize self.write_connection_file() File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\ipykernel\kernelapp.py", line 230, in write_connection_file write_connection_file(cf, ip=self.ip, key=self.session.key, transport=self.transport, File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file with secure_write(fname) as f: File "D:\IDE\Anaconda3\envs\pytorch\lib\contextlib.py", line 113, in __enter__ return next(self.gen) File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\jupyter_client\connect.py", line 100, in secure_write win32_restrict_file_to_user(fname) File "D:\IDE\Anaconda3\envs\pytorch\lib\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user import win32api ImportError: DLL load failed while importing win32api: 找不到指定的程序。

The solution is:

pip install pywin32==228

An error commandnotfounderror (to initialize your shell) is reported when activating the virtual environment

Error in activating virtual environment

PS E:\projects\Text2Scene_v3> conda activate base

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - xonsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

Windows10 + vscode
after all the information found on the Internet is used, it is found that it is useless
later, I found out why the previous one was PS (base) or not. As a result, I changed the terminal from power shell to CMD emmmmm~~

Mistakes vary from person to person. It may take a lot of unnecessary time to solve them, but patience will always solve them, rush
If I can’t solve this problem, go and see someone else’s~~

Syntax Error: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position resolution

Error reporting: syntax error: (Unicode error) ‘Unicode scape’ codec can’t decode bytes in position 2-3: tr

For example, in the file, the file path I passed in is like this

sys.path.append('c:\Users\mshacxiang\VScode_ project\web_ ddt')

Cause analysis: the file path can be read in the windows system, but \ has escape meaning in the Python string. For example, \ t can represent tab and \ n represents line feed. Therefore, we need to take some measures to prevent \ from being interpreted as escape characters. Add r before the path to keep the original value of the character. This solves the problem

sys.path.append(r'c:\Users\mshacxiang\VScode_ project\web_ ddt')

Vscode configures eslint to solve terminal syntax error

1. Problem scenario

Pull the code from GitHub or build the project with the scaffold Vue cli. The terminal has syntax errors that do not comply with eslint, which is very uncomfortable

2. Solutions

First, install eslint

Second, configure setting

File – & gt; Preferences – & gt; Settings – & gt; Search eslint

Fill in the following configuration code

// By default, vscode has enabled the option to automatically set tabsize based on file type

"editor.detectIndentation": false,

// Reset tabsize

"editor.tabSize": 2,

// # Automatically format each time it is saved

"editor.formatOnSave": true,

// # Fix the code in eslint format every time it saves

"eslint.autoFixOnSave": true,

// Add vue support

"eslint.validate": [

  "javascript",

  "javascriptreact",

  {
    "language": "vue",

    "autoFix": true

  }

],

//  #Let prettier use eslint's code format for checksums

"prettier.eslintIntegration": true,

// # Remove the semicolon at the end of the code

"prettier.semi": false,

// # Use quoted instead of double quotes

"prettier.singleQuote": true,

// # Make a space between the function (name) and the parentheses that follow it No space false

"javascript.format.insertSpaceBeforeFunctionParenthesis": false,

// # Make the js in vue formatted according to the editor's own ts format

"vetur.format.defaultFormatter.js": "vscode-typescript",

"vetur.format.defaultFormatterOptions": {
  "js-beautify-html": {
    "wrap_attributes": "force-aligned"

    // # formatting styles for html code in vue components

  }

},

"window.zoomLevel": 0,

"explorer.confirmDelete": false,

"explorer.confirmDragAndDrop": false,

"editor.renderControlCharacters": true,

"editor.renderWhitespace": "all",

"editor.codeActionsOnSave": {
  "source.fixAll.eslint": true

}

Step 3 open . Eslitrc. JS of the project

Fill in the following configuration code

// https://eslint.org/docs/user-guide/configuring

 

module.exports = {
  root: true,

  parserOptions: {
    parser: 'babel-eslint'

  },

  env: {
    browser: true

  },

  extends: [

    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention

    // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.

    'plugin:vue/essential',

    // https://github.com/standard/standard/blob/master/docs/RULES-en.md

    'standard'

  ],

  // required to lint *.vue files

  plugins: ['vue'],

  // add your custom rules here
  rules: {
    // allow async-await
    'no-console': 'off',
    indent: ['error', 2, { SwitchCase: 1 }],
    semi: ['error', 'always'],
    'space-before-function-paren': [
      'error',
      { anonymous: 'always', named: 'never' }
    ],
    'generator-star-spacing': 'off',
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ?'error' : 'off'
  }
}