I am new to python and I guess pyCharm is the most preferred IDE for python but I want to stick to vscode if possible. I have the python extension installed in vscode and autocomplete works fine for default python packages but for external packages like pillow or PyPDF2, its not working.
I created a virtual environment where I installed the above 2 packages using pip and even checked if the packages are installed using pip freeze
.
Pip freeze is showing:
Pillow==9.0.1
PyPDF2==1.26.0
Below is my project structure. I need to import PyPDF2 module from basic.py. Also, if it helps, I am using python 3.9.6. Any help or suggestions are greatly appreciated.
CodePudding user response:
Did you select the interpreter inside the vscode?
Enter vscode and type
ctrl shift p
and type in command prompt
>python:Select Interpreter
and then activate the Interpreter. This will do the trick for you.
CodePudding user response:
You need to select the interpreter by following the docs.
Through the python extension, you can set the interpreter so that the packages will be taken from the environment. The interpreter is basically the python that your virtual env uses so it has access to the python packages that you installed in the virtual env.
Here are the steps in case the docs change:
- CTRL Shift P or Command Shift P depending on if you're on Windows or Mac respectively
- Type
Python: Select Interpreter
after the>
- Then you can either select the interpreter from your virtual env that you created or enter the path to the interpreter.