I'm trying to import three modules that I've installed with pip: requests, bs4, and pillow. I'm installing them from the command line, but I'm attempting to import them from both the command line and Anaconda. The problem is that bs4 and pillow are unavailable from the command line, and pillow is unavailable from within Anaconda
# installing bs4 (other installations have been omitted for brevity)
PS C:\Users\xxxx\AppData\Local\Programs\Python\Python38\Lib> pip install bs4
Processing c:\users\xxxx\appdata\local\pip\cache\wheels\0a\9e\ba\20e5bbc1afef3a491f0b3bb74d508f99403aabe76eda2167ca\bs4-0.0.1-py3-none-any.whl
Requirement already satisfied: beautifulsoup4 in c:\users\xxxx\anaconda3\lib\site-packages (from bs4) (4.9.1)
Requirement already satisfied: soupsieve>1.2 in c:\users\xxxx\anaconda3\lib\site-packages (from beautifulsoup4->bs4) (1.9.5)
Installing collected packages: bs4
Successfully installed bs4-0.0.1
# verifying that requests, bs4, and pillow are in the list of installed modules
PS C:\Users\xxxx\AppData\Local\Programs\Python\Python38\Lib> pip list | Select-string "requests|bs4|pillow"
bs4 0.0.1
Pillow 7.2.0
requests 2.24.0
PS C:\Users\xxxx\AppData\Local\Programs\Python\Python38\Lib>
# starting Python and trying to import the module
PS C:\Users\xxxx\AppData\Local\Programs\Python\Python38\Lib> py
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> import bs4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bs4'
>>> import pillow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pillow'
I noticed that my packages keep installing in C:\users\xxxx\anaconda3\lib\site-packages, but the problem seems to be that they need to install in the C:\Users\xxxx\AppData\Local\Programs\Python\Python38\Lib directory. I was able to copy the folder that contains the "requests" module over to C:\Users\xxxx\AppData\Local\Programs\Python\Python38\Lib, and now I can import it from the command line and from within Anaconda.
However, after installing bs4 and pillow, bs4 can be imported from Anaconda but not imported on the command line and pillow cannot be imported from Anaconda or the command line.
I have already tried pip3, but I get an error saying that that is not a recognized command.
I have tried uninstalling bs4 and pillow, running $PYTHONPATH = "C:\Users\xxxx\AppData\Local\Programs\Python\Python38\Lib"
, and reinstalling the modules. I got a message saying that the requirements for bs4 were already satisfied, and it said that it installed pillow. Still, neither are available from the command line
UPDATE: I repaired Python, and now I can import bs4, but I still cannot import pillow from the command line or from within Anaconda. Also, when I type out "python" into the command line instead of just "py", I get this warning message:
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
When I try to activate my conda environment, per the website in the warning message, I don't get any errors in the activation process, but the warning message persists:
PS C:\Users\xxxx> conda info --envs
# conda environments:
#
base * C:\Users\xxxx\Anaconda3
PS C:\Users\xxxx> conda activate base
PS C:\Users\xxxx> python
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>>