-2

I am running two sources of python

  1. From anaconda3 [/home/aravind/anaconda3/bin/python]

  2. CIAO python ( used for X-ray astrophysical data analysis) [/usr/local/soft/ciao_410/ciao-4.10/bin/python]

There are some conflicts between the two versions such as (2) doesn't allow astropy module and (1) doesn't allow ciao tools !

Is there a way I can switch between the two versions of python installed within the code ? Like say calling up the anaconda installation when astropy has to be imported and switch back immediately to use ciao tools.

In my .cshrc file, I call upon both versions but by default the anaconda version is above the ciao version in the source file and thus is the default version when I initiate a new terminal.

I apologise if I am not clear enough. I am new to this field and am having some difficulties.

Thanks

Astronomer
  • 99
  • 1
  • 1
  • 7
  • Possible duplicate of [How to use virtualenv with Python?](https://stackoverflow.com/questions/35017160/how-to-use-virtualenv-with-python) – Jim Stewart Aug 06 '18 at 16:54
  • Can virtualenv be used within a code ? – Astronomer Aug 06 '18 at 16:58
  • 1
    Sorry Aravind, but no, you shouldn't do this. I'm not sure if that's sufficient for an answer, but you can't run simultaneous python versions for a lot of reasons in any realistic way – en_Knight Aug 06 '18 at 16:59

1 Answers1

0

If your operating system is Linux, you can use this method to change Python:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2

sudo update-alternatives --config python 

Enter the desired Python number for example :
Output of Command

If your operating system is Windows:
C:\Windows\System32\>"C:\python2.7\python.exe" your_script.py

Milad Gialni
  • 46
  • 1
  • 8