CondaValueError: Malformed version string '~': invalid character(s)
Asked Answered
B

6

30

I'm getting a Malformed version string error with my conda. I have no idea how to debug this or how to check it.

Can anyone help? GitHub has talked about the issue but I haven't seen any fixes.

-bash-4.1$ conda install -c bioconda pysam
Solving environment: failed



 1. CondaValueError: Malformed version string '~': invalid character(s).

In response to the comment below:

(mage_env) -bash-4.1$ echo $PATH
/usr/local/devel/ANNOTATION/jespinoz/anaconda/envs/mage_env/bin:/usr/local/packages/jdk-8u121/bin/:/usr/local/bin:/usr/local/devel/ANNOTATION/rrichter/local/bin:/home/syooseph/utils/clustalw1.83:/usr/local/packages/gsl/bin:/usr/local/sge_current/bin/lx-amd64:/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/devel/ANNOTATION/jespinoz/anaconda/bin:/usr/local/devel/ANNOTATION/jespinoz/Dropseq/:/usr/local/devel/ANNOTATION/jespinoz/Dropseq/Drop-seq_tools-1.13/
(mage_env) -bash-4.1$ conda info

     active environment : mage_env
    active env location : /usr/local/devel/ANNOTATION/jespinoz/anaconda/envs/mage_env
            shell level : 1
       user config file : /home/jespinoz/.condarc
 populated config files : /home/jespinoz/.condarc
          conda version : 4.5.11
    conda-build version : not installed
         python version : 3.6.2.final.0
       base environment : /usr/local/devel/ANNOTATION/jespinoz/anaconda  (writable)
           channel URLs : https://conda.anaconda.org/ursky/linux-64
                          https://conda.anaconda.org/ursky/noarch
                          https://conda.anaconda.org/bioconda/linux-64
                          https://conda.anaconda.org/bioconda/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /usr/local/devel/ANNOTATION/jespinoz/anaconda/pkgs
                          /home/jespinoz/.conda/pkgs
       envs directories : /usr/local/devel/ANNOTATION/jespinoz/anaconda/envs
                          /home/jespinoz/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.11 requests/2.14.2 CPython/3.6.2 Linux/2.6.32-696.18.7.el6.x86_64 centos/6.4 glibc/2.12
                UID:GID : 3456:63
             netrc file : None
           offline mode : False
Boeke answered 10/5, 2019 at 21:18 Comment(1)
Hi @merv I've added the conda info.Boeke
F
29

This looks like it was fixed with Conda 4.6.0. Upgrading your Conda should resolve the issue.

conda upgrade -n base conda

If you have trouble solving environment, I suggest trying

conda upgrade -n base -c defaults --override-channels conda

This will exclude all other channels during the solving process, and helps because having too many options to prune is one of the main reasons for slow solves.

Foursquare answered 13/5, 2019 at 16:16 Comment(10)
I've been running it for a few hours and it keeps solving :( Solving environment: /Boeke
Try conda upgrade -n base -c defaults --override-channels conda. This will turn off the bioconda and conda-forge channels temporarily for this install.Foursquare
When I use the command: conda upgrade -n base -c defaults --override-channels conda It gave warning A newer version of conda exists and asks to use conda update -n base -c defaults conda when I run this command I go back to the same error in the main question.Micrography
@Micrography that latter suggestion is only if you're having solve troubles. It sounds like you have a different issue (can't upgrade Conda), so search for that, or ask a new question.Foursquare
This issue is quite terrible. Currently, the only solution is to fresh install conda with python version >= 3.6: github.com/conda/conda/issues/8732. How could someone make an API breaking change that broke even the possibility of upgrading conda...?Overbold
Is there an alternative workaround when I don't have root permission to upgrade conda?Sylphid
@Sylphid Not really. Let your sys admins know that they should upgrade Conda. Otherwise, this really comes from PyPI packages that have ~= dependencies. So, avoid using pip in your Conda envs. If you must, then you would have to manually edit the offending packages to remove the ~=, e.g., replacing it with >=, but you'd need to do this on a case-by-case basis.Foursquare
you can add a new environment and install all your libraries again using condaAmidase
can someone explain what if I do not have the permission to do the update on base environement. I only want to resolve the problem on the environment I am working as a non-root user?Evert
@AZiZASaber use MicromambaFoursquare
P
2

I needed to remove conda-forge from my .condarc file. Then everything worked fine.

Piloting answered 2/5, 2021 at 21:56 Comment(0)
S
1

I had the similar problem

conda upgrade -n base conda

did pull the latest version but did not make the upgrade as I did not clear my previous install properly before installing latest anaconda.

Removing /root/anaconda3 ( default installation folder in my case ) & removing /root/.conda & reinstalling the latest anaconda

Post that

conda upgrade -n base conda

would help you upgrade to 4.16+ version ( as of today, its latest )

One Additional Step which one must follow if they are importing env from one machine to this one:

remove specific version from conda package dependency, example here:

https://gitlab.com/mkuhring/TaxIt/-/commit/a8587e41bfff4c3362556c1c46d23d99ac3af069

Soundboard answered 2/9, 2022 at 6:43 Comment(0)
D
0

Had the same issue with conda 4.8.2 while I tried to create an environment from a yaml file.

loading a different, already existing environment and unloading it again did the trick in multiple occasions.

Dynel answered 27/5, 2020 at 18:10 Comment(0)
A
0

I got this error also when trying to install a package to a personal directory on an HPC, as in:

$ conda install -c dranew shapeit 
Solving environment: failed
CondaValueError: Malformed version string '~': invalid character(s).

As a user of the HPC I'm not in control of the version of conda installed so had to find another solution.

This ended up working:

$ conda create --name shapeit -c dranew shapeit

or in generic terms,

$ conda create --name <packagename> -c <conda_channel_name> <packagename>

This tells conda to create an environment named packagename, then find the package in its channel (dranew for shapeit, bioconda for OP) and install it in that new environment.

I don't know if it makes a difference, but I ran this code when inside my .conda/envs directory.

Hope this helps someone else!

Anarthrous answered 24/8, 2022 at 12:27 Comment(0)
A
0

remove - conda-forge from the .condarc file is useful for me.

Acanthaceous answered 23/7, 2024 at 2:50 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.