I am making a project using Python and have a virtual environment installed called venv
. Here is the information for the virtual environment:
Version and Modules Installed:
I am on a linux machine that has a package installed called whois
via apt
.
I am using VSC and its built-in terminal.
Here is the code that I run using the terminal with the virtual environment activated.
The following error occurs when the code tries to import the module.
┌──(venv)─(narwhal㉿WhoAreWe)-[~/Documents/Projects/PassCon]
└─$ python ./WHOIS/custom_whois.py
Traceback (most recent call last):
File "/home/narwhal/Documents/Projects/PassCon/./WHOIS/custom_whois.py", line 1, in <module>
import whois
ModuleNotFoundError: No module named 'whois'
I have tried to not use the virtual environment and run it normally and it does work but from what I understand it is using the whois
package installed via apt
(I found out that it doesn't work as I am using whois()
instead of query()
which is used by the APT-installed whois
).
I also have uninstalled and re-installed python-whois
multiple times.
I do not wish to uninstall the apt
version of whois as I need it for my day to day. I doubt that its the problem, but I hope its not the only solution to fix my problem.
I also want to use python-whois
so it is easily installed for users.
Thanks to Gabe and Rasjani for showing me how to check the directory in which my virtual environment was checking for installed modules, I have figured out the solution.
First, I used python -m site
to check the directory listing and searched each one and noticed that PIP was not installed in any of them and none of them had the modules I "installed".
The simplest fix was to uninstall my current virtual environment and follow this step-by-step on how to properly initiate a virtual environment, check if its successful, and install the modules.
Lesson learned: Don't blindly jump in and properly set up your environment.