Python package isnt upgraded despite running `conda install` - python

I have a conda enviroment called Vik. One of the packages installed is TBB (tbb=2018.0.5). I want to upgrade to version 2019.5 or later because my code returns this warning. NumbaWarning: The TBB threading layer requires TBB version 2019.5 or later
Thus, I went on and installed the latest TBB (at least this is what I believe). I havent kept the original message log but It looked normal to me. I am under the impression that the package was successfully installed. When I try to install it again this is what I get
(base) C:\Windows\system32>conda activate Vik
(Vik) C:\Windows\system32>conda install -c conda-forge tbb
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
but it appears that i am still calling the old version 2018.0.5. The numba warning that I need to upgrade tbb is still there when I run my application and conda env export -n Vik > environment.yml generates the following list. At the bottom of the list below you can clearly see that the package hasnt been updated. Note that the package doesnt appear under the pip section of the environment.yml shown below, hence it should be a conda package.
What am I doing wrong?
name: Vik
channels:
- anaconda
- conda-forge
- defaults
dependencies:
- anyio=3.2.0=py37h03978a9_0
- argon2-cffi=20.1.0=py37he774522_1
- async_generator=1.10=py37h28b3542_0
- attrs=21.2.0=pyhd3eb1b0_0
- babel=2.9.1=pyh44b312d_0
- backcall=0.2.0=py_0
.....
.....
.....
- sqlite=3.35.3=h2bbff1b_0
- tbb=2018.0.5=he980bc4_0
- terminado=0.9.1=py37_0

The conda install -c conda-forge tbb directive translates to the imperative
With the channel conda-forge prioritized, ensure that the currently activated environment has some version of tbb installed.
Since tbb is already installed, that directive is already satisfied.
If you want a newer version, either use conda update -c conda-forge tbb or specify a version, e.g., conda install -c conda-forge tbb=2021.

Related

Cannot find package for Python 3.7.8

I am completly new to Conda and I have been struggling for a day without success.
I would like to use the pvtrace module. The documentation specifically says to run the following commands to install the package:
conda create --name pvtrace-env python=3.7.8
conda activate pvtrace-env
conda install Rtree
pip install pvtrace
I have the following error:
PackagesNotFoundError: The following packages are not available from current channels:
- python=3.7.8
I have Anaconda 3 which original Python version is 3.9. I installed the version 3.7, but it did not solve my problem.
Not sure why, but the defaults (main/anaconda) channels are missing specifically the Python 3.7.8 build. This is available through Conda Forge, so, instead try
## one should prefer to list all known package at creation
conda create -n pvtrace-env -c conda-forge python=3.7.8 pip rtree
conda activate pvtrace-env
pip install pvtrace
Alternatively, use a YAML file:
pvtrace-env.yaml
name: pvtrace-env
channels:
- conda-forge
dependencies:
- python=3.7.8
- rtree
- pip
- pip:
- pvtrace
which is used as:
conda env create -n pvtrace-env -f pvtrace-env.yaml

How to make sure python version is running correctly

I'm relatively new to Jupyter Notebook and have been struggling with python versions with Jupyter Notebook.
I installed seaborn but import error occurred saying no seaborn package found. It shows on upper right corner of Jupyter "Python 3" but it returned Python 2.7 when I run !python --version. Also when I run print(sys.path), the result is below.
['', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mysql-0.0.1-py3.5.egg', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/extensions', '/Users/Cynthia/.ipython']
My guess is that my python kernel isn't pointing correctly to python3 although notebook shows it's python3. Could someone pls help me solve this? It would be helpful if there could be code to run in Jupyter cell. Thank you!
When you run python --version, It won't spit python 3.5.x, because python refers to python2 unless you aliased python as python3. So it makes sense that you see python 2.7.x when you run python --version.
As for py2 when you run conda env list, they are env names you set. They are just names, not python versions.
What needs to be done I think is to find out where your jupyterlab is installed, which I think in (base) environment. In your base environment, run conda list, where you will see a list like this:
(base) ➜ test conda list
# packages in environment at /Users/gwanghyeongim/.pyenv/versions/miniconda3-latest:
#
# Name Version Build Channel
brotlipy 0.7.0 py38haf1e3a3_1000
ca-certificates 2020.6.24 0
certifi 2020.6.20 py38_0
cffi 1.14.1 py38hed5b41f_0
chardet 3.0.4 py38_1003
conda 4.8.4 py38_0
conda-package-handling 1.6.1 py38h1de35cc_0
cryptography 2.9.2 py38ha12b0ac_0
idna 2.10 py_0
libcxx 10.0.0 1
libedit 3.1.20191231 h1de35cc_1
libffi 3.3 hb1e8313_2
ncurses 6.2 h0a44026_1
openssl 1.1.1g h1de35cc_0
pip 20.2.2 py38_0
pycosat 0.6.3 py38h1de35cc_1
pycparser 2.20 py_2
pyopenssl 19.1.0 py_1
pysocks 1.7.1 py38_1
python 3.8.3 h26836e1_1
python.app 2 py38_10
readline 8.0 h1de35cc_0
requests 2.24.0 py_0
#and so on...
See if you see jupyterlab in the list. If so, your jupyter notebook is in (base) environment.
Now the most likely scenario is you installed seaborn in py2 environment. That means you dind't install seaborn in your base environment. Install it by running conda install seaborn or pip install seaborn.
If something didn't work so far, try runnning conda upgrade --all -y to upgrade packages. It might be from collision between deprecated packages.
P.S
My suggestion is you create a separate environment and run packages on it.
Run conda create -n your_env_name to do so(replace your_env_name to the name you want set)
Activate by running conda activate the_env_you_just_created
If 2 doesn't work somehow, make sure you run conda init your_shell, where your_shell can be found by running echo $SHELL, where the last word after / is your shell.
Make sure you see (your_env_name) at the first part of command prompt. If so, your env is activated. Now install packages on here and do your project, rather than on base environment.
Since you mentioned you use conda you can do something like the following. From your terminal:
conda create -n sb python=3
conda activate sb
conda config --env --add channels conda-forge
conda install -y pandas matplotlib numpy scipy seaborn jupyterlab # some default packages
jupyter lab
Whenever you want to use this conda environment again you have to do
conda activate sb
before you can run jupyter lab.
Note, if you didn't changed the default, you should see your terminal prompt changing when activating an environment, i.e. the name of the environment comes before your prompt. In our case here (sb) <prompt>.
To solve the issue with your current conda environment, more information is needed.

using pip as a low priority 'channel' in conda environment

Is there a way to use pip as a 'fallback' option for some packages in a conda environment, like you can have multiple prioritized conda channels?
For normal conda channels, my environment.yml would be as follows:
name: my_env
channels:
- defaults
- conda-forge
dependencies:
- some-package>=1.2.3
Where some-package would be installed from default channels if possible, or conda-forge otherwise. It would fail if neither channel has the appropriate package version.
The environment.yml with pip:
name: my_env
channels:
- defaults
- conda-forge
dependencies:
- pip
- pip:
- some-package>=1.2.3
Where some-package would always come from pip.
But what I want is something like this:
name: my_env
channels:
- defaults
- conda-forge
dependencies:
- some-package>=1.2.3
- pip
- pip:
- some-package>=1.2.3
Where the package would come from defaults first, else conda-forge, or else from pip.
However, this gives a ResolvePackageNotFound error before trying pip. Is there any way to achieve this?
I've read somewhere that conda shall be extended to allow satisfying dependencies with pip-installed packages. But I cannot find the reference with a quick search, and I don't think it's a production-ready feature anyway. And what I remember was not conda installing pip packages, but conda accepting already present packages that have been installed by pip.
Anaconda packages define their dependencies in terms of other Anaconda packages. Therefore, conda resolves dependencies of Anaconda packages within its own world of packages and metadata. Some packages don't even have the same name in Anaconda channels and on PyPI.
In other words: No, I don't think that what you want is possible. You'll have to call pip when you want something installed by pip.

UnsatisfiableError: pyqt and py-opencv in conflict

For my College project, i tried installing pyqt with command conda install pyqt=4 but it shows error as shown below (even this error comes after solving environment for few minutes).
I am new to these stuffs, can anyone please help me over this!
(tensorflow_cpu) F:\BE project\TensorFlow\addons\labelImg>conda install pyqt=4
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- py-opencv
- pyqt=4
Use "conda info <package>" to see the dependencies for each package.
The problem is that py-opencv requires python 3.6 or above where as pyqt=4 requires python2.7. Hence there will be a conflict between these two packages.
To avoid this conflict and use both the packages together, follow the below steps. Note that here the pyqt version will get upgrade to 5.9.2
Commands:
Create a new conda environment to avoid package mismatches.
conda create -n pyqt python=3.6
Here pyqt is the conda environment name
Activate the environment:
activate pyqt
Install py-opencv
conda install -c anaconda py-opencv
Install pyqt package:
conda install -c alges pyqt
While executing this step, pyqt version will be 5.9.2
Now you will be able to use both the packages with python3.6

Anaconda python: Pinning channel and not package version

Every time I use conda install -c some_channel to install a Python package, conda tries to update other packages from some_channel. From example, here I'm trying to install hdbscan from conda-forge, and conda wants to update ca-certificates as well.
The following NEW packages will be INSTALLED:
hdbscan: 0.8.18-py36h7eb728f_0 conda-forge
The following packages will be UPDATED:
ca-certificates: 2018.03.07-0 anaconda --> 2018.8.24-ha4d7672_0 conda-forge
certifi: 2018.8.24-py36_1 anaconda --> 2018.8.24-py36_1001 conda-forge
openssl: 1.0.2p-h1de35cc_0 anaconda --> 1.0.2p-h470a237_1 conda-forge
Proceed ([y]/n)? n
Note that conda tries to do this even if the package versions from the two channels are identical. So this is not just about upgrading to newer version.
Can I pin the channel for packages without pinning the version numbers? I wouldn't mind updating ca-certificates if the update comes from anaconda channel.

Categories