How To Create Python Project In Anaconda
Getting started with Anaconda¶
Anaconda Individual Edition contains conda and Anaconda Navigator, as well as Python and hundreds of scientific packages. When you installed Anaconda, you installed all these too.
Conda works on your command line interface such as Anaconda Prompt on Windows and terminal on macOS and Linux.
Navigator is a desktop graphical user interface that allows you to launch applications and easily manage conda packages, environments, and channels without using command-line commands.
You can try both conda and Navigator to see which is right for you to manage your packages and environments. You can even switch between them, and the work you do with one can be viewed in the other.
Try this simple programming exercise, with Navigator and the command line, to help you decide which approach is right for you.
When you're done, see What's next?.
Your first Python program: Hello, Anaconda!¶
Use Anaconda Navigator to launch an application. Then, create and run a simple Python program with Spyder and Jupyter Notebook.
Run Python in Spyder IDE (integrated development environment)¶
Tip
Navigator's Home screen displays several applications for you to choose from. For more information, see links at the bottom of this page.
-
On Navigator's Home tab, in the Applications pane on the right, scroll to the Spyder tile and click the Install button to install Spyder.
Note
If you already have Spyder installed, you can jump right to the Launch step.
-
Launch Spyder by clicking Spyder's Launch button.
-
In the new file on the left, delete any placeholder text, then type or copy/paste
print("Hello Anaconda")
. -
In the top menu, click File - Save As and name your new program
hello.py
. -
Run your new program by clicking the triangle Run button.
-
You can see your program's output in the bottom right Console pane.
Close Spyder¶
From Spyder's top menu bar, select Spyder - Quit Spyder (In macOS, select Python - Quit Spyder).
Run Python in a Jupyter Notebook¶
-
On Navigator's Home tab, in the Applications pane on the right, scroll to the Jupyter Notebook tile and click the Install button to install Jupyter Notebook.
Note
If you already have Jupyter Notebook installed, you can jump right to the Launch step.
-
Launch Jupyter Notebook by clicking Jupyter Notebook's Launch button.
This will launch a new browser window (or a new tab) showing the Notebook Dashboard.
-
On the top of the right hand side, there is a dropdown menu labeled "New". Create a new Notebook with the Python version you installed.
-
Rename your Notebook. Either click on the current name and edit it or find rename under File in the top menu bar. You can name it to whatever you'd like, but for this example we'll use MyFirstAnacondaNotebook.
-
In the first line of the Notebook, type or copy/paste
print("Hello Anaconda")
. -
Save your Notebook by either clicking the save and checkpoint icon or select File - Save and Checkpoint in the top menu.
-
Run your new program by clicking the Run button or selecting Cell - Run All from the top menu.
Close Jupyter Notebook¶
- From Jupyter Notebooks top menu bar, select File - Close and Halt.
- Click the Quit button at the upper right of the Notebook Dashboard and close the window or tab.
Write a Python program using Anaconda Prompt or terminal¶
Open Anaconda Prompt¶
Choose the instructions for your operating system.
- Windows.
- macOS.
- Linux.
Windows
From the Start menu, search for and open "Anaconda Prompt":
macOS
Open Launchpad, then click the terminal icon.
Linux
Open a terminal window.
Start Python¶
At Anaconda Prompt (terminal on Linux or macOS), type python
and press Enter.
The >>>
means you are in Python.
Write a Python program¶
At the >>>
, type print("Hello Anaconda!")
and press Enter.
When you press enter, your program runs. The words "Hello Anaconda!" print to the screen. You're programming in Python!
Exit Python¶
On Windows, press CTRL-Z and press Enter. On macOS or Linux type exit()
and press Enter.
Optional: Launch Spyder or Jupyter Notebook from the command line¶
- At the Anaconda Prompt (terminal on Linux or macOS), type
spyder
and press Enter. Spyder should start up just like it did when you launched it from Anaconda Navigator. - Close Spyder the same way you did in the previous exercise.
- At the Anaconda Prompt (terminal on Linux or macOS), type
jupyter-notebook
and press Enter.
Jupyter Notebook should start up just like it did when you launched it from Anaconda Navigator. Close it the same way you did in the previous exercise.
What's next?¶
How To Create Python Project In Anaconda
Source: https://docs.anaconda.com/anaconda/user-guide/getting-started/
Posted by: grahamladmoultan.blogspot.com
0 Response to "How To Create Python Project In Anaconda"
Post a Comment