I have a new Mac and I installed python 3 using brew install python
.
[~]$ which python3 rbenv:system
/usr/local/bin/python3
[~]$ python3 --version rbenv:system
Python 3.8.6
I ran the following command: pip3 install -r requirements.txt which has lxml==4.5.2 in it.
It installed fine with no errors. If I run it again I get this:
Requirement already satisfied: lxml==4.5.2 in /usr/local/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (4.5.2)
However whenever I try to import lxml, I get an error:
[~]$ python3 rbenv:system
Python 3.8.6 (default, Oct 8 2020, 14:06:32)
[Clang 12.0.0 (clang-1200.0.32.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lxml'
>>>
Any ideas how to resolve this, I am using ohmyZSH so do I need to add anything to my .zshrc?
Some info on pip3:
*[master][~/src/Arelle]$ which pip3 rbenv:system
/usr/local/bin/pip3
*[master][~/src/Arelle]$ pip3 --version rbenv:system
pip 20.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
The problem is that python3
and pip3
can be binaries that use different versions of Python. Furthermore, there are virtual environments, which give you a local site-packages
(folder for installed packages).
The best way to use pip COMMAND
is with python3 -m pip COMMAND
. That way you always know what Python installation your pip
is doing work for.
In your case, run
python3 -m pip install lxml
in order to get lxml
where you want it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.