Issue
--
EDIT - conda list
output (top few lines)
# packages in environment at C:\ANACONDA3:
#
# Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py39haa95532_0
alabaster 0.7.12 pyhd3eb1b0_0
altair 4.1.0 pypi_0 pypi
--
I was originally using spyder v4
and python v3.7
, but needed to update python to 3.9 for some software. I removed spyder (conda remove spyder
), updated python (conda install python=3.9
) and reinstalled spyder (conda install spyder=4.2
). Upon starting spyder I had a dependency issue, so also updated that (conda update nbconvert
). Everything starts fine - I have the correct spyder and python versions.
When working previously i had a lot of packages installed with pip (pip install X). These packages are located in my anaconda directory (C:\ANACONDA3\Lib\site-packages
). There were no issues with this before the updates, but now I get import errors - for example, I previously did pip install primer3
(link), and have used it successfully, but now I get:
import primer3
Traceback (most recent call last):
Cell In[3], line 1
import primer3
File C:\ANACONDA3\lib\site-packages\primer3\__init__.py:40
from .bindings import (calcHairpin, calcHomodimer, calcHeterodimer,
File C:\ANACONDA3\lib\site-packages\primer3\bindings.py:40
from . import thermoanalysis
ImportError: cannot import name 'thermoanalysis' from partially initialized module 'primer3' (most likely due to a circular import) (C:\ANACONDA3\lib\site-packages\primer3\__init__.py)
I have heard that pip and conda dont play that well together, but only after I had been using pip for a while - I am very much an amateur. However, seeing as they were installed into the anaconda directory, I assume that I was using the conda pip rather than a standalone local pip, and this should be fine?
Can anyone advise what the issue is/how to fix it? Whilst this has been an interesting learning experience, I have a lot of broken code now :(
Cheers! Tim
Solution
Since you have a mix of conda
and pip
installed packages in your base environment, the conda install python=3.9
command might have broken some of your pip
installed packages. The best idea is probably to reinstall them:
pip uninstall primer3-py
pip install primer3-py
For now, for any pip
installed package only (conda list
includes the information if something is installed via conda or pip), that shows misbehaviour after this update, you can try the same approach. Do make sure to only do this for pip packages. Note that a lot of packages in your base came with anaconda and are managed by conda. These should all be the correct version for your new python version.
when you have some time, I would recommend the following cleanup approach:
- Uninstall anaconda
- Reinstall <- this will give you a clean base environment again
- For all your projects, create and use a virtual environment created with
conda
This enables you to manage different dependencies more effectively in the future. Also, if an environment breaks beyond repair, other projects are not affected and you can delete and recreate.
Answered By - FlyingTeller
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.