python – Pip freeze listing out global packages in conda env

I am using conda as my environment and created a new environment for a project. After installing packages in that env using pip I used pip freeze -r requirements.txt to save my package dependencies in requirements.txt file, but all package that is installed globally is being added to the requirements file. How can track packages installed in the env only?

Here is the step I followed:

1. conda create -n tf_env 
2. conda activate tf_env
3. pip install pandas

Then when I do pip freeze -l, I get the following output:

adal==1.2.2
affine==2.3.1
aiohttp==3.6.2
aiohttp-retry==2.4.6
alabaster==0.7.12
alembic==1.7.7
altair==4.2.0
aniso8601==9.0.1
appdirs==1.4.4
applicationinsights==0.11.9
apturl==0.5.2
argcomplete==1.8.1
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
asn1crypto==1.4.0
asttokens==2.0.5
async-timeout==3.0.1
asyncssh==2.10.1
atpublic==3.0.1
attrs==19.3.0
audioread==2.1.9
avro==1.11.0
azure==4.0.0
azure-ai-textanalytics==1.0.0b1
azure-appconfiguration==1.0.0
azure-applicationinsights==0.1.0
....

and many more packages that are installed globally. Thought I should only get pandas and related dependencies.

Read more here: Source link