This is because you need to create a virtual environment and install the package there. Then it’ll work.
To create a virtual environment, run the following:
python3 -m venv name_of_environment #to activate the environment source name_of_environment/bin/activate # to exit of the environment deactivate
You’ll see the environment active because it’ll show the name at the far left of the terminal.
Now you can go ahead and install the package using PIP and the yellow squiggly lines should be gone.
I also noticed that after exiting (deactivate) the environment, the package won’t give you the error anymore. So it’s like you have to install while active in the environment and then you’re free to exit or stay within it.
Press the following to select the interpreter:
CMD + SHFT + P
Choose “Python: Select Interpreter” and from the dropdown select the virtual environment you just created.
python3 -m pip install module_name
From there, reload VSCode (SHFT + CMD + P) and select Reload Window
Install these modules in this order to make PythonTurtle and tk work. You might also need to name the virtual environment “venv“
python3 -m pip install PythonTurtle python3 -m pip install tk
Select the virtual environment as the python interpreter, type: SHFT + CMD + P and select python interpreter, and then select the virtual environment you created as the interpreter.
The only problem I’m noticing with this is that the default turtle module won’t work. You’ll get an error that says tkinter can’t be imported. I’m still working to solve this problem.
*This might be solved or it was just a one time thing that it worked. What I’m thinking is that I entered the folder by doing “source venv/bin/activate” instead of using “source ./venv/bin/activate”
Have any questions or comments? Write them below!