Basically, I downloaded the library using pip install PyDictionary
and I made sure it exists by writing the same thing again and this appeared:
Requirement already satisfied: PyDictionary in c:usersziadappdatalocalprogramspythonpython39libsite-packages (2.0.1) Requirement already satisfied: bs4 in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from PyDictionary) (0.0.1) Requirement already satisfied: goslate in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from PyDictionary) (1.5.1) Requirement already satisfied: requests in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from PyDictionary) (2.25.1) Requirement already satisfied: click in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from PyDictionary) (7.1.2) Requirement already satisfied: beautifulsoup4 in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from bs4->PyDictionary) (4.9.3) Requirement already satisfied: soupsieve>1.2 in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from beautifulsoup4->bs4->PyDictionary) (2.2.1) Requirement already satisfied: futures in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from goslate->PyDictionary) (3.1.1) Requirement already satisfied: idna<3,>=2.5 in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from requests->PyDictionary) (2.10) Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from requests->PyDictionary) (1.26.4) Requirement already satisfied: chardet<5,>=3.0.2 in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from requests->PyDictionary) (4.0.0) Requirement already satisfied: certifi>=2017.4.17 in c:usersziadappdatalocalprogramspythonpython39libsite-packages (from requests->PyDictionary) (2020.12.5)
However, when I try to run this simple program in atom, it says module not found. This is the program:
from PyDictionary import PyDictionary dictionary = PyDictionary() print (dictionary.meaning("indentation"))
This is the error:
Traceback (most recent call last): File "C:UsersZiadDesktopprogramsDictionary.py", line 1, in <module> from PyDictionary import PyDictionary ModuleNotFoundError: No module named 'PyDictionary'
The only way I found to execute the program correctly was by moving the file to the folder where the library exists so that atom can find the library. The weird thing is that the library numpy works perfectly. I would really like an answer to this problem.
Advertisement
Answer
What you’re having issues with is that your pip
command, is not connected to your installation of python3
.
If you’re using Windows, then you should have a “python launcher” that you can use to double-check your installed versions of Python like this:
PS C:> py -0 Installed Pythons found by C:windowspy.exe Launcher for Windows -3.9-64 * -3.7-32
Here you can see that I have two versions of Python installed on my device. So, let’s check what both of those installations has installed using their own versions of pip
.
Let’s start with my 3.7
installation:
PS C:> py -3.7 -m pip list Package Version ------------------ --------- beautifulsoup4 4.8.1 Jinja2 2.11.2 keyring 21.2.0
Here we can see that I have three packages installed.
Now let’s check my 3.9
installation:
PS C:> py -3.9 -m pip list Package Version -------------------------------- --------- matplotlib 3.4.1 numpy 1.19.4 pandas 1.1.5 pip 21.0.1
What I am doing above basically, is calling the different python
installations, and opening it with the following flag:
-m mod : run library module as a script (terminates option list)
The pip
command is basically just an alias for <python-installation> -m pip
, so when I issue the above command, I am launching pip
with a specific python-installation.
If you do not have the “python-launcher” that I have in my above examples, but you have different aliases for your python-interpreters, then you can issue the same commands in the same way, just using your aliases.
Here are a couple of examples:
# will show you the installed packages for the alias "python2" python2 -m pip list # will show you the installed packages for the alias "python3" python3 -m pip list
And you can obviously issue other commands to pip
using that same logic, so if you want to install a package for a specific version you can do something like:
# will try to install the given package for the alias "python3" python3 -m pip install <nameOfPackage>