<p>Could you download it from <code>conda</code> and try again? Its here, <a href="https://docs.conda.io/en/main/miniconda.html" rel="nofollow noreferrer">https://docs.conda.io/en/main/miniconda.html</a></p>
<p>Then,</p>
<pre><code>conda create --name myenv
conda activate myenv
conda install -c bioconda cnvkit
cnvkit batch /path/to/my/folder/with/bams/*.bam --normal --targets ${bed_file} --fasta path/to/my/resources_broad_hg38_v0_Homo_sapiens_assembly38.fasta --output-reference /path/to/my/CD_BATCH1_reference.cnn --output-dir /path/to/my/Group_1 --scatter 
</code></pre>
<p>The path to the file is not used, the command is simply <code>cnvkit</code>
This avoids all the privilege stuff and ensures you're running a virtual environment to protect your system Python.</p>
<hr />
<p>To address the comments. &quot;conda&quot; is slow and doesn't ever load.</p>
<p>There is an alternative to conda called <strong>mamba</strong>, this is fast and designed to address this exact issue. I have never needed to use it so the following is a rough guide only.</p>
<p>Download and install via</p>
<pre><code>conda create --name myenv
conda activate myenv
conda install -c conda-forge mamba
</code></pre>
<p>The documentation is here, <a href="https://mamba.readthedocs.io/en/latest/user_guide/mamba.html" rel="nofollow noreferrer">https://mamba.readthedocs.io/en/latest/user_guide/mamba.html</a></p>
<p>I've never used it but the idea is ...</p>
<pre><code>mamba create -n mambaenv &lt;list of packages&gt;
mamba activate mambaenv
</code></pre>
<p>The list of packages could be left blank for now, then,</p>
<pre><code>mamba install &quot;Python&gt;=3.10.0&quot; numpy pandas pathlib
mamba install cnvkit # SEE NOTE
</code></pre>
<p>Can also do</p>
<pre><code>mamba install -n mambaenv cnvkit
</code></pre>
<p><strong>NOTE</strong> cnvkit exists strictly in -c bioconda. You do not seem to search and install via channels in mamba</p>
<p>You search for a package and its dependencies via</p>
<pre><code>mamba repoquery search cnvkit
mamba repoquery depends -a cnvkit
</code></pre>
<p>It is important to place a virtual environment between the system Python and package Python (don't want a system corruption). More to the question, this would solve all the permission problems without changing your system in anyway (kinda important).</p>

CC BY-SA 4.0
2023-05-12T13:37:19.990Z
I did try this before and I tried it again now but for whatever reason I get `Solving environment: failed with initial frozen solve. Retrying with flexible solve.` over and over again. It never works though for the command `conda install -c bioconda cnvkit`.
Indira
CC BY-SA 4.0
2023-05-12T13:52:37.660Z
Okay @Indira thanks. Addressed above
M__
CC BY-SA 4.0
2023-05-12T15:05:28.470Z
"I have never needed to use it" you lucky so-and-so! We regular joes need to stick to mamba if we need conda environments solved in one human lifetime.
Ram RS
CC BY-SA 4.0
2023-05-12T17:33:00.013Z
@RamRS this is funny. I suggest the reason is that "Regular Joses" (pronounced Hosays) where I am, don't use conda. "Regular Joes" where you are, all use conda. Thus your server always times out. :-)
M__
CC BY-SA 4.0
2023-05-11T20:33:54.967Z
2023-05-12T14:29:51.863Z
2023-05-12T14:29:51.863Z
M__
<p>I am trying to run some code for my colleague in bash</p>
<pre><code>/path/to/cnvkit.py batch /path/to/my/folder/with/bams/*.bam \
  --normal --targets ${bed_file} \
  --fasta path/to/my/resources_broad_hg38_v0_Homo_sapiens_assembly38.fasta \
  --output-reference /path/to/my/CD_BATCH1_reference.cnn \
  --output-dir /path/to/my/Group_1 --scatter
</code></pre>
<p>however, I keep getting this truly peculiar error</p>
<pre><code>Traceback (most recent call last):
  File &quot;/path/to/cnvkit.py&quot;, line 4, in &lt;module&gt;
    from . import commands
ImportError: cannot import name 'commands' from '__main__' (/path/to/cnvkit.py)
</code></pre>
<p><strong>Attempt 1</strong></p>
<p>I checked if the path was correct and multiple times I found that it was correct. It did not change the error.</p>
<p><strong>Attempt 2</strong></p>
<p>Perhaps I need to <code>chmod +x *</code> everything in the CNV kit directory and that will help. It did not change the error.</p>
<p>Why is this error occurring? How do I solve this issue?</p>

<bash><cnv>
CNV Kit ` from . import commands ImportError: cannot import name 'commands' from '__main__'`
# CNV Kit ` from . import commands ImportError: cannot import name 'commands' from '__main__'`

(Asked by: username_0 on 2023-05-11)

I am trying to run some code for my colleague in bash
/path/to/cnvkit.py batch /path/to/my/folder/with/bams/*.bam \
  --normal --targets ${bed_file} \
  --fasta path/to/my/resources_broad_hg38_v0_Homo_sapiens_assembly38.fasta \
  --output-reference /path/to/my/CD_BATCH1_reference.cnn \
  --output-dir /path/to/my/Group_1 --scatter

however, I keep getting this truly peculiar error
Traceback (most recent call last):
  File "/path/to/cnvkit.py", line 4, in 
    from . import commands
ImportError: cannot import name 'commands' from '__main__' (/path/to/cnvkit.py)

Attempt 1
I checked if the path was correct and multiple times I found that it was correct. It did not change the error.
Attempt 2
Perhaps I need to chmod +x * everything in the CNV kit directory and that will help. It did not change the error.
Why is this error occurring? How do I solve this issue?

**Tags:** bash, cnv

---

## 1 answers

### Answer by username_1 on 2023-05-11. Score: 1 | Accepted answer

Could you download it from conda and try again? Its here, https://docs.conda.io/en/main/miniconda.html
Then,
conda create --name myenv
conda activate myenv
conda install -c bioconda cnvkit
cnvkit batch /path/to/my/folder/with/bams/*.bam --normal --targets ${bed_file} --fasta path/to/my/resources_broad_hg38_v0_Homo_sapiens_assembly38.fasta --output-reference /path/to/my/CD_BATCH1_reference.cnn --output-dir /path/to/my/Group_1 --scatter 

The path to the file is not used, the command is simply cnvkit
This avoids all the privilege stuff and ensures you're running a virtual environment to protect your system Python.

To address the comments. "conda" is slow and doesn't ever load.
There is an alternative to conda called mamba, this is fast and designed to address this exact issue. I have never needed to use it so the following is a rough guide only.
Download and install via
conda create --name myenv
conda activate myenv
conda install -c conda-forge mamba

The documentation is here, https://mamba.readthedocs.io/en/latest/user_guide/mamba.html
I've never used it but the idea is ...
mamba create -n mambaenv 
mamba activate mambaenv

The list of packages could be left blank for now, then,
mamba install "Python>=3.10.0" numpy pandas pathlib
mamba install cnvkit # SEE NOTE

Can also do
mamba install -n mambaenv cnvkit

NOTE cnvkit exists strictly in -c bioconda. You do not seem to search and install via channels in mamba
You search for a package and its dependencies via
mamba repoquery search cnvkit
mamba repoquery depends -a cnvkit

It is important to place a virtual environment between the system Python and package Python (don't want a system corruption). More to the question, this would solve all the permission problems without changing your system in anyway (kinda important).

> **Comments:**
> **username_0**: I did try this before and I tried it again now but for whatever reason I get `Solving environment: failed with initial frozen solve. Retrying with flexible solve.` over and over again. It never works though for the command `conda install -c bioconda cnvkit`.  
> **username_1**: Okay @Indira thanks. Addressed above  
> **username_2**: "I have never needed to use it" you lucky so-and-so! We regular joes need to stick to mamba if we need conda environments solved in one human lifetime.  
> **username_1**: @RamRS this is funny. I suggest the reason is that "Regular Joses" (pronounced Hosays) where I am, don't use conda. "Regular Joes" where you are, all use conda. Thus your server always times out. :-)  

---

