I am using a desktop with Linux (specifically Pop_OS! 20.04, which is analogous to ubuntu).
I need to run ASE which is python package for atomistic simulations. This can be installed in several ways (apt, pip, conda). For my purpose I need to install it with conda (to be as consistent as possible with the community). Since I do not like the way conda is integrated in bash, I decided to use pyenv as Virtual Environment manager.
Accordingly to answer 1 on another stackoverflow question, it is better not to install conda through pyenv. So in my simple mind firstly I tried this (CASE A):
- I create a virtual environment with pyenv;
- I install conda using the proper script and now pyenv
- within the environment and using conda I install ASE
$ pyenv virtualenv 3.9.0 caseA
(caseA) $ which python
/home/fex/.pyenv/shims/python
(caseA) $ python -V
Python 3.9.0
(caseA) $ bash Anaconda3-2020.07-Linux-x86_64.sh
# I did not include anaconda in the bashrc
# To activate conda eval "$(/home/user/anaconda3/bin/conda shell.YOUR_SHELL_NAME hook)" or "source <path to conda>/bin/activate"
# conda init
(baseA) $ source /home/fex/anaconda3/bin/activate
(base) (caseA) $
This double enviroment is quite interesting, and I think it should not happen.
Yet I could not install ASE with conda. So I gaveconda init
:
(base)(caseA) $ conda init
(base)(caseA) $ source ~/.bashrc
(base) $ conda install -c conda-forge/label/cf202003 ase
(base) $ ase test
...
fio/oi.py: TypeError: Object does not appear to be a file-like object
========== Summary ==========
Number of tests 363
Passes: 260
Failures: 0
Errors: 1
Skipped: 102
=============================
Test suite failed!
Time elapsed: 42.3 s
As far as I understand this method works, but bypass pyenv and I end up just using a conda environment which is not what i want in first place.
CASE B: This is not crucial. Once I created the environment I tried to install conda with pyenv, but I could not manage to use it within the pyenv environment.
CASE C: I solve the problem in the following way:
- Installed conda with pyenv
- create a pyenv virtual environment that relies on conda and not a specific version of python
$ pyenv virtualenv miniconda3.X.Y fooenv
- This works for me, but I am using the python included in conda. This is not a problem, but since I am not completely grasping the full technicality here I wanted to share my doubts.
Another reason because I wrote here is that ASE is a pretty popular standard in the field of DFT (Density Functional Theory) which at date is one of the most cited topic in chemistry/physics fields. Yet the writing of manuals and guides does not keep up with the fast pace of python.
Extra info
$ pyenv versions
system
2.7.18
* 3.9.0 (set by PYENV_VERSION environment variable)
3.9.0/envs/caseA
3.9.0/envs/caseB
3.9.0/envs/coppie
3.9.0/envs/foo
caseA
caseB
ccase
coppie
foo
miniconda3-latest
miniconda3-latest/envs/ccase # I created this with pyenv virtualenv miniconda3-latest ccase ccase stands for case C
$ pyenv -v
pyenv 1.2.21
$ which python
/home/fex/.pyenv/shims/python
$ python -V
Python 3.9.0
pyenv activate ccase
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(ccase) $ pip install pytest
(ccase) $ ase test
[...]
====================================================================== 1290 passed, 233 skipped, 1 xfailed, 5 warnings in 193.06s (0:03:13)