Virtual Environment, Anaconda

Hello guys,

I’m using Anaconda. I have two environments, namely BASE and SHOONYA that use the same version of python. I installed a package in SHOONYA that requires pandas 1.5, after this my BASE environment pandas also gets affected.

Please let me know if I’m doing something wrong.

Before installing package

(base) ┌──(kali㉿kali)-[~/Desktop/shoonya]
└─$ pip show pandas | grep -i version
Version: 2.1.4

(shoonya) ┌──(kali㉿kali)-[~/Desktop/shoonya]
└─$ pip show pandas | grep -i version
Version: 2.1.4+dfsg

I’m using this command to install package

(shoonya) ┌──(kali㉿kali)-[~/Desktop/shoonya]
└─$ pip install NorenRestApi-0.0.28-py2.py3-none-any.whl

After installing package

(shoonya) ┌──(kali㉿kali)-[~/Desktop/shoonya]
└─$ pip show pandas | grep -i version              
Version: 1.5.3

(base) ┌──(kali㉿kali)-[~/Desktop/shoonya]
└─$ pip show pandas | grep -i version
Version: 1.5.3

If you use conda, I would advise to avoid using pip and only use conda. Only when there is no way to install sth with conda, should you use pip. Otherwise you can end up with seriously broken conda environments, especially for packages (like pandas) that contains extension modules and that have many other dependencies.

Pip is not a virtual environment manager, so

Pip and conda also differ in how dependency relationships within an environment are fulfilled. When installing packages, pip installs dependencies in a recursive, serial loop. No effort is made to ensure that the dependencies of all packages are fulfilled simultaneously. This can lead to environments that are broken in subtle ways, if packages installed earlier in the order have incompatible dependency versions relative to packages installed later in the order.

(Anaconda | Understanding Conda and Pip)

It can be very hard to fix this once you’re in a situation as you described. The safest/easiest/fastest option may be to just start over from scratch (from new, clean conda envs). If the new package “NorenRestApi” is not available on conda, then the safest way to install it is to make sure that you first use conda install for pandas 1.5 (and any other important dependency that is not a pure-Python package) before doing a pip install of “NorenRestApi”.

2 Likes

Thank You Hans for your support, will take care of this.