skip to Main Content

When I use the following command to create a new virtual environment, it succeeds.

conda create -n my_env python=3.7

But when I wanted to export the package of the new environment to the requirements.txt file, I found that many other packages were already installed.

asgiref==3.3.4
asn1crypto==0.24.0
attrs==17.4.0
Automat==0.6.0
backports.entry-points-selectable==1.1.0
certifi==2018.1.18
chardet==3.0.4
click==6.7
colorama==0.3.7
configobj==5.0.6
constantly==15.1.0
cryptography==2.1.4
distlib==0.3.2
distro-info===0.18ubuntu0.18.04.1
Django==3.1.3
django-debug-toolbar==3.2.1
django-filter==2.4.0
djangorestframework==3.12.2
filelock==3.0.12
httplib2==0.9.2
hyperlink==17.3.1
idna==2.6
importlib-metadata==4.6.4
importlib-resources==5.2.2
incremental==16.10.1
keyring==10.6.0
keyrings.alt==3.0
language-selector==0.1
mysqlclient==2.0.3
netifaces==0.10.4
PAM==0.4.2
platformdirs==2.2.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycrypto==2.6.1
pygobject==3.26.1
pyOpenSSL==17.5.0
pyserial==3.4
python-apt==1.6.4
python-debian==0.1.32
pytz==2021.1
pyxdg==0.25
PyYAML==3.12
requests==2.18.4
requests-unixsocket==0.1.5
SecretStorage==2.3.1
service-identity==16.0.0
six==1.11.0
sqlparse==0.4.1
ssh-import-id==5.7
systemd-python==234
Twisted==17.9.0
typing-extensions==3.7.4.3
ufw==0.36
urllib3==1.22
virtualenv==20.7.2
wrapt==1.12.1
zipp==3.5.0
zope.interface==4.3.2

So what should I do to create a pure Python virtual environment? In other words, when I export the package for a new virtual environment, I will get a blank requirements.txt. Thanks.

2

Answers


  1. When I create my_ven at least with conda 4.9.2 the environment seems to be empty.

    >conda create -n my_env python=3.9
    >conda activate my_env
    >pip freeze
    certifi==2021.5.30
    wincertstore==0.2
    
    
    Login or Signup to reply.
  2. This is likely due to either a PYTHONPATH variable being defined, or having previously installed packages at the system- or user-level (e.g., pip install --user).

    To have properly isolated Python environments (what Conda expects), users should have PYTHONPATH unset and remove all user-level packages (typically in ~/.local/lib/python*/site-packages).

    The reason why installing a different version of Python leads to a clean interpreter REPL is because Python packages are only compatible up to minor versions. That is, you either have another Python 3.7 in PYTHONPATH, or you have a ~/.local/lib/python3.7/site-packages.

    See additional documentation on Using Pip with Conda.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search