Reputation: 23
After activating a python virtual environment at the terminal with source ./venv/bin/activate
, and running python3 in the venv, it doesn't seem to have the packages from the venv in the path.
(venv) d@MBP-2020 scrapers % ls venv/lib/python3.11/site-packages | grep "pandas"
pandas
pandas-1.5.2.dist-info
(venv) d@MBP-2020 scrapers % pip list | grep "pandas"
pandas 1.5.2
(venv) d@MBP-2020 scrapers % python3
Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24 2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
>>> import sys; print(sys.path)
['', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python311.zip', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages']
I thought activating the venv would put the venv-installed packages in the right path for the python3 executable? Must I manually add the site-packages directory to the path somehow?
What is the right workflow to access packages installed venvs with python?
Upvotes: 2
Views: 2638
Reputation: 308
this pip is not match you cmd python3
run python env,
you can use whereis pip
and whereis python3
to check you pip and python3 real link to where.
venv/lib/python3.11/bin/python
, this env is your grep cmd search dir,and is installed pandas lib py env,you can usr pyenv
or conda
to manage you mulit version.
Upvotes: 1