Skip to content

Instantly share code, notes, and snippets.

@offby1
Created August 6, 2023 15:30
Show Gist options
  • Save offby1/4607f6af5d291de01b43d7de4394cfdc to your computer and use it in GitHub Desktop.
Save offby1/4607f6af5d291de01b43d7de4394cfdc to your computer and use it in GitHub Desktop.
Typical discord session, helping someone past the "I just installed my package with pip, but python doesn't see it" problem
[7:24 AM]Deleted User: I downloaded a plugin via pip but Python doesn't recognize it
— 01/24/2021 7:24 AM
[7:25 AM]offby1: you have two or more versions of python installed
[7:26 AM]offby1: you used one of them to install the package, and are now using the other to try to run it. This doesn't work.
[7:26 AM]offby1: figure out which version you're running now, and use that version to install the package again
[7:26 AM]Deleted User: I have Python 3.9
[7:26 AM]Deleted User: I just downloaded it because my C drive got wiped
[7:26 AM]offby1: I will bet you you also have some other version as well
[7:27 AM]offby1: what exactly did you type originally when you ran pip?
[7:27 AM]Deleted User: pip install pychroma
[7:27 AM]offby1: can you run that command again, and capture the output, and paste it (preferably as text, not an image)
[7:28 AM]offby1: I suspect that ran some older version of python but would like to see
[7:28 AM]Deleted User:
C:\Users\gastg>pip install pychroma
Requirement already satisfied: pychroma in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (0.0.2)
Requirement already satisfied: pynput>=1.6.8 in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (from pychroma) (1.7.2)
Requirement already satisfied: requests>=2.23.0 in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (from pychroma) (2.25.1)
Requirement already satisfied: six in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (from pynput>=1.6.8->pychroma) (1.15.0)
Requirement already satisfied: idna<3,>=2.5 in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (from requests>=2.23.0->pychroma) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (from requests>=2.23.0->pychroma) (2020.12.5)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (from requests>=2.23.0->pychroma) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\gastg\appdata\local\programs\python\python39\lib\site-packages (from requests>=2.23.0->pychroma) (1.26.2)
[7:28 AM]offby1: thanks!!
[7:28 AM]offby1: oh, it sure looks like python39 😐
[7:29 AM]offby1: ok, my next hypotheses: you're using an IDE that is using a virtualenv
[7:29 AM]Deleted User: I use Pycharm as IDE
[7:29 AM]offby1: yep
[7:29 AM]Deleted User: I think so
[7:29 AM]offby1: in the program that's failing, can you put these lines at the very top, so that they'll run before your import fails:
import sys
print(sys.executable)
[7:29 AM]offby1: then run it and tell me what it says
[7:30 AM]Deleted User:
"E:\Programme\PyCharm\Python Projects\RazerChroma-Python\venv\Scripts\python.exe" "E:/Programme/PyCharm/Python Projects/RazerChroma-Python/main.py"
Traceback (most recent call last):
File "E:\Programme\PyCharm\Python Projects\RazerChroma-Python\main.py", line 4, in <module>
import pychroma
ModuleNotFoundError: No module named 'pychroma'
E:\Programme\PyCharm\Python Projects\RazerChroma-Python\venv\Scripts\python.exe
Process finished with exit code 1
[7:30 AM]offby1: I predict it will not be c:\users\gastg\appdata\local\programs\python\python39\bin\python.exe
[7:31 AM]offby1: yeah that's it
[7:31 AM]offby1: so ...
[7:31 AM]offby1: there's probably some official "pycharm" way to do it, but I bet this will work
c:\> "E:\Programme\PyCharm\Python Projects\RazerChroma-Python\venv\Scripts\python.exe" -m pip install pychroma
[7:32 AM]offby1: try dat, report back 🙂
[7:32 AM]Deleted User:
C:\Users\gastg>"E:\Programme\PyCharm\Python Projects\RazerChroma-Python\venv\Scripts\python.exe" -m pip install pychroma
Collecting pychroma
Using cached pychroma-0.0.2-py3-none-any.whl (10 kB)
Collecting pynput>=1.6.8
Using cached pynput-1.7.2-py2.py3-none-any.whl (99 kB)
Collecting requests>=2.23.0
Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting six
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting chardet<5,>=3.0.2
Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting urllib3<1.27,>=1.21.1
Using cached urllib3-1.26.2-py2.py3-none-any.whl (136 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Collecting idna<3,>=2.5
Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Installing collected packages: urllib3, six, idna, chardet, certifi, requests, pynput, pychroma
Successfully installed certifi-2020.12.5 chardet-4.0.0 idna-2.10 pychroma-0.0.2 pynput-1.7.2 requests-2.25.1 six-1.15.0 urllib3-1.26.2
[7:32 AM]offby1: now try your program; I predict success
[7:33 AM]Deleted User: Yep, it recognizes it
[7:33 AM]offby1: 💐
[7:33 AM]Deleted User: And it uses the module
[7:33 AM]Deleted User: Thank you so much!
[7:33 AM]offby1: I should really save this session with you and add it to some FAQ somewhere ... people have this problem all the time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment