简体   繁体   中英

`Why is Visual Studio Code not recognising an installed Python Module?

Recently, I started learning python . I'm at the 8th chapter of a book called "Automate the Boring stuff with Python" . The author uses a module named 'pyinputplus'. I installed this module with pip (pip3) and tried to play with it in my terminal, and it worked.

After playing around with this module, I decided to make a small project in Visual Studio Code . I had the "Python" plug-in installed. (It was made by Microsoft, and it had linting, debugging, syntax highlighting and more.) Strangely, it started throwing errors. This was my code:

import pyinputplus as pyip

It seems to work fine without the plug-in, although running it without the plug-in wasn't very convenient, as I had to run it in my terminal every time.

This was what is was saying:

Cannot import 'pyinputplus' due to syntax error 'invalid syntax (, line 268)'

Obviously, I didn't have this many lines in my code. (I had only one line of code.) I'm guessing this is a bug, but as a beginner I'm not really sure. Does anyone else have this problem? Any answer would be appreciated.

Here are my plug-ins in use, Vscode version, etc.

  • MacOS Version: 10.14.6
  • VsCode version: 1.47.2
  • Python-related plug-ins/extensions: 'Code Runner' and 'Python'
  • Python version: 3.8.4

I tried reloading VSCode, But it still didn't work.

First, you have to install that module on your computer. By using:

pip install pyinputplus

Then, you can import it by:

import pyinputplus as pyip

and then, you will get results like this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM