Anaconda + vscode usage problem summary

anaconda+vscode use problem

1, anaconda environment in vscode can not be used in the problem

  1. installation plug-in
    python and Anaconda Extension Pack
  2. in Anaconda configure corresponding environment
    here in addition to the base I also configure python and tfenv environment, here we take tfenv as an example, we can set the compiler version we want 2.x or 3.x, we can also install the package we want, very convenient.
  3. select our compiler

    > in the lower left corner we can choose which interpreter we want to interpreter. Then, from the middle option that appears, we select the pen-to-last one which is tfenv: Conda environment
  4. to install the corresponding package
    our program needs the matplotlib package, first we install the package in anaconda, as shown in the figure, click apply (we can also install the matplotlib through the corresponding command of anaconda in CMD, we will not go into details here)

    after we install the matplotlib package, we run as shown in the figure, showing “ModuleNotFoundError: “No module named ‘matplotlib’ is mainly because although we chose the corresponding python.exe interpreter, the environment corresponding to tfenv did not import

    . There are two solutions
  • vscode default terminal is generally powershell: powershell solution
  • set terminal to CMD, then activate the tfenv environment with the command activate tfenv, and there will be no problem in running the program
  • Read More: