Blame view

docs/source/python_anaconda.rst 3.37 KB
96482ab2   Alain Klotz   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.. _anaconda_install:

***************************************************
Installing Python with Anaconda
***************************************************

Anaconda is an environment of development well designed for science use.
Any version of Python can be installed using virtual environments.
Spyder is a code editor allowing an easy write and execution of Python code.
Jyputer Notebook allos to create nice tutorials. 

Informations about `Anaconda <https://www.anaconda.com>`_.

1. Virtual environments of Anaconda
***********************************

If you want to create a project named *my_project* that uses GuitAstro, we recommand to create
a virtual environment (my_project) to not disturb other Python applications.

We define two kind of prompts in the command shell:

* **$** = prompt of the normal environment
* **(my_project) $** = prompt of the virtual environment named *my_project*

To create the virtual environment *my_project* with Python version 3.7 and Spyder:

.. code-block:: bash

	$ conda create -n my_project python=3.7 spyder

To use the virtual environment my_project. The prompt changes:

.. code-block:: bash

	$ conda activate my_project
	(my_project) $

After installation of Anaconda default virtual environment can be accessed: (base).
One can go anywhere in the disk with this environment and build application with Python 3.7.

When we want to quit the virtual environment

	(my_project) $ conda deactivate
	$

In virtual environments Python is launched using command python. For example:

.. code-block:: bash

	$ conda activate my_project
	(my_project) $ python

Now, pip will install packages only in the selected virtual environment. 

Spyder of virtual environment my_project can be called as:

.. code-block:: bash

	$ conda activate my_project
	(my_project) $ spyder

Sometimes, in Linux, Spyder enconter a conflict of libstdc++.so.6. If Spyder crashes at launch,
simply remove the file ~/anaconda3/lib/libstdc++.so.6. For example:

.. code-block:: bash

	mv ~/anaconda3/lib/libstdc++.so.6 ~

 
2. Linux installation of Anaconda
*********************************

.. code-block:: bash

	$ cd
	$ wget https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh
	$ bash Anaconda3-5.3.1-Linux-x86_64.sh

Answer to questions by yes. At the end, you must make updates:

.. code-block:: bash

	$ source .bashrc
	$ conda update --all
	(base) $

At the end, the prompt indicates we are in the (base) virtual environment.

Now you can create any virtual environment you want.

To launch Spyder of a given virtual environment (my_projet) you can create an icon on desktop.
In case of Gnome Ubuntu:

.. code-block:: bash

	$ cd
	$ cd Desktop
	$ gedit spyder_base.desktop

	[Desktop Entry]
	Name=Spyder base
	Exec="/home/xxx/anaconda3/envs/my_project/bin/spyder"
	Icon=/home/xxx/anaconda3/envs/my_project/share/icons/spyder3.png
	Type=Application
	Terminal=false
	Categories=Development;Application

Note: Destop is called Bureau in French version.

A grayed icon appears on the desktop. You must activate is with the contextual menu item Allow execution".

3. Windows installation of Anaconda
***********************************

Link for download `Anaconda (all operating systems) <https://www.anaconda.com/products/distribution>`_.

Follow the standard installation.

After the installation, before using python you must set paths in environment variables:

.. toctree:: 
   :maxdepth: 3

   windows_paths