The following example shows a simple Python program for displaying the message 'Welcome to Data Mining' The program is stored in a file named dm.py. You can also write your Python program using a text editor and save it in a file with a '.py' extension. To exit the interpreter, type quit() at the interpreter's command prompt. For example, to display the message 'Welcome to Data Mining!' on the screen, type: > print('Welcome to Data Mining!') The interpreter is now ready to accept your Python commands. Type "help", "copyright", "credits" or "license" for more information. To invoke the interpreter, type 'python' on the Anaconda command prompt: C:\Users\Default> python Instead, it requires another program, called an interpreter, to read and execute the Python program. Python is generally considered an interpreted language, which means its program cannot be directly executed by your machine. This section provides some examples on how to write and execute your Python program. How to Write and Execute Your Python Program ¶ In that case, you can still install the package using the 'pip' command: C:\Users\Default> pip install package_nameĢ. Some Python packages may not be part of Anaconda's distribution. Where package_name is the name of the Python library package you would like to install. To install a specific package, type the following: C:\Users\Default> conda install package_name For example, to check whether a specific package name is installed on your machine, you can type the following: C:\Users\Default> conda list package_name You can also use 'conda list' to check whether a specific package has been installed. To check all the packages installed on your machine, type the following command: C:\Users\Default> conda list You can also type the conda update command without searching for outdated packages. To search for outdated package, type the following on Anaconda command prompt: C:\Users\Default> conda search -outdated Updating and Installing Additional Python Library Packages ¶Īfter installing the base Python distribution packages, you should check to see if any of the installed packages are outdated. Note that any text that follows the '#' character are simply comments to help explain the meaning of each command.ġ.3. C:\Users\Default> activate p圓6 # to launch the new environmentĬ:\Users\Default> python -version # check to make sure it is the new version of PythonĬ:\Users\Default> deactivate # to exit from the environmentĬ:\Users\Default> python -version # this will display the older version of Python The commands for activating and deactivating the new environment are shown below. After creating the environment, you need to activate the new environment from the command prompt before launching Python 3.6 and deactivate it when you're done. Where the -n p圓6 option specifies the name of the environment, python=3.6 is the name and version of the package to be installed, and anaconda is the name of the meta-package that contains all the Python packages of the Anaconda distribution. To do this, you must first launch the the Anaconda command prompt and type the following: C:\Users\Default> conda create -n p圓6 python=3.6 anaconda If you already have an older version of Python (e.g., version 2.7) installed on your machine and would like to upgrade it to a newer version, you can create an environment for installing the new version without overwriting the older one. Upgrade from an Older Version of Python ¶
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |