I am relatively new to programming and get an error message during my initial PyCharm setup as written in the manual (see screenshots) after passing this command:
import subprocess
I am following these steps here: Editor Setup - Writing Anki Add-ons
I am on a 64bit Python version (3.10.4.).
You are pasting the command into your shell prompt but you should be pasting it into a python REPL. In this case, you have a terminal open in pycharm. Instead, you should open a python console and paste the commands in there. Alternatively, you could type python
into the terminal to start a python session in the terminal and paste the commands there.
3 Likes
Also, subprocess
is used to make OS calls from python, but a shell directly allows you make these calls right away, so it’s a bit weird to start a python repl just to launch a sub process. For instance, in your shell prompt, if you wanted to do subprocess.*(["pip3", "install", "--upgrade", "pip"])
(where *
is any subprocess function that actually starts a subprocess, including check_call
), you can just type pip3 install --upgrade pip
in your shell prompt.
3 Likes