Tag suggestion: Use the correct python to install packages
greyblue9 opened this issue · 0 comments
Tag Name
which-python
What kind of content should the tag include?
This is just a thought I have had a few times that could help our users and staff, I don't have any formal md content in mind yet, but if there is interest, I am happy to take a stab at it.
Motivation
A common problem is that users will install some package using pip install
, but then they can't import it from their IDE because either a different python version is being used, or else a venv is in use in the IDE (which is the default for PyCharm)
What The Tag Should Do
Explain that pip is tied to a particular python, and it may not be the same one the IDE is using. Both IDE and command line must agree on where packages are installed. There can be different python versions in use, and/or there can be a venv in use in the IDE, which seems to be the more common issue.
Instructions
If the IDE indicates it's using a venv (as vscode does in the lower-left corner), and the user has installed a package with pip install
, they should either
- Not use venv in IDE: Change the Python interpreter to the system python by clicking the python button in the lower-left corner (vscode) or by going to Project Settings -> Interpreter (PyCharm)
- Reinstall packages using the venv's
pip
: If keeping the venv is desired, the user shouldcd
to the directory for their project and use./myvenv/bin/pip install
(or.\myvenv\bin\pip install
in cmd on Windows) to install the desired package to the venv's site-packages.
Final Thought
While it's not necessarily easy to explain, it would save a lot of back-and-forth (and people opening help channels and/or complaining they can't post screenshots) if we can distill it down to an easily digestible tag.
Bonus: Use python3.x -m pip
or py -3.x -m pip
when installing packages instead of pip
to make sure they get installed for the correct python version