Pages

Showing posts with label python 3. Show all posts
Showing posts with label python 3. Show all posts

Sunday, December 9, 2018

Fedora 29 : Python 3 and Jupyter notebook.

Today I tested the Jupyter Notebook with Fedora 29.
About the Jupyter Notebook the official website comes with this intro:
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
First I check with DNF tool the update and the upgrade of the Fedora 29 distro.
The next step was to install this:
# dnf install python3-pip
# dnf install python3-devel.x86_64
# pip3 install --upgrade pip
With my account shell I used this commands to create and run the Jupiter Notebook:
$ pip3 install --user virtualenv
$ mkdir my_project
$ cd my_project/
$ virtualenv my_project_env
$ source my_project_env/bin/activate
$ pip3 install jupiter
$ jupiter notebook
The last command will start your default browser and will see this:
You can see I created a new notebook with Python 3.
The result is shown into another tab webpage browser where I used few commands to install new module scipy and I check if this working well:
!pip3 install scipy
help
quickref
The result of this notebook looks like this image:

Monday, June 25, 2018

Fedora 28 : Using the python module sh .

Today I test another python module named sh with python version 3.6.5 and Fedora 28.
This python module named sh is a full-fledged subprocess replacement for Python 2.6 - 3.5, PyPy and PyPy3 that allows you to call any program as if it were a function.
You can read bout this python module here.
I used dnf tool to search and install the pip tool :
[root@desk mythcat]# dnf search python3
Last metadata expiration check: 1:06:29 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
======================== Name Exactly Matched: python3 =========================
...
python3.x86_64 : Interpreter of the Python programming language
Next step is the install of python programming language:
[root@desk mythcat]# dnf install python3.x86_64 
Last metadata expiration check: 1:09:12 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
Package python3-3.6.5-1.fc28.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
...
I search the pip tool and then I install it:
[root@desk mythcat]# dnf search python3-pip
Last metadata expiration check: 1:15:18 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
====================== Name Exactly Matched: python3-pip ======================
python3-pip.noarch : A tool for installing and managing Python3 packages
...
[root@desk mythcat]# dnf install python3-pip.noarch 
Last metadata expiration check: 1:16:31 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
Package python3-pip-9.0.3-2.fc28.noarch is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
...
The install of this python module into user mode:
[root@desk mythcat]# exit 
exit
...
[mythcat@desk ~]$ pip3.6 install --user sh
Requirement already satisfied: sh in /usr/lib/python3.6/site-packages
See next examples and tests I used :
[mythcat@desk ~]$ python3.6
Python 3.6.5 (default, Mar 29 2018, 18:20:46) 
[GCC 8.0.1 20180317 (Red Hat 8.0.1-0.19)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sh
>>> from sh import *
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1017, in _handle_fromlist
  File "/usr/lib/python3.6/site-packages/sh.py", line 3349, in __getattr__
    return self.__env[name]
  File "/usr/lib/python3.6/site-packages/sh.py", line 3187, in __getitem__
    Please import sh or import programs individually.")
RuntimeError: Cannot import * from sh. Please import sh or import programs individually.
...
>>> print(sh.ifconfig)
/usr/sbin/ifconfig
>>> print(sh.ifconfig())
...
>>> print(sh.ls())
...
>>> print(sh.ls("-l"))
...
>>> print(sh.uptime())
 11:25:03 up  1:52,  1 user,  load average: 1.10, 1.04, 1.40
...

Friday, June 1, 2018

Fedora 28 : Using python to create old GUI.

The asciimatics python module provides a widgets sub-package that allows you to create interactive text user interfaces.
This python module lets you create full-screen text UIs and interactive forms to ASCII animations. The python module was created to working with any platform and python version 2 and 3.
It is licensed under the Apache Software Foundation License 2.0, see this license here.
Let see the installation process using the Fedora 28 and python version 3.6:
[root@desk mythcat]# dnf install python3
Last metadata expiration check: 2:39:44 ago on Fri 01 Jun 2018 12:51:55 PM EEST.
Package python3-3.6.5-1.fc28.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
You need also to install the asciimatics python module using the pip tool:
[mythcat@desk ~]$ pip3.6 install --user asciimatics
Collecting asciimatics
  Using cached https://files.pythonhosted.org/packages/.../asciimatics-1.9.0-py2.py3-none-any.whl
Requirement already satisfied: future in /usr/local/lib/python3.6/site-packages (from asciimatics)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/site-packages (from asciimatics)
Requirement already satisfied: Pillow>=2.7.0 in /usr/lib64/python3.6/site-packages (from asciimatics)
Requirement already satisfied: pyfiglet>=0.7.2 in /usr/local/lib/python3.6/site-packages (from asciimatics)
Installing collected packages: asciimatics
Successfully installed asciimatics-1.9.0
I tested some sample from the author GitHub account and is working good.
Some samples require some extra python module and you will need to install them.

Saturday, March 17, 2018

Fedora 27 : Testing the new Django web framework .

Today I tested the Django web framework version 2.0.3 with python 3 on my Fedora 27 distro.
The main reason is to see if the Django and Fedora working well.
I used the pip to install and activate the virtual environment for python. First you need to create your project into your folder. I make one folder named django_001.
$ mkdir django_001
$ cd django_001
The next step is to create and activate the virtual environment for python language and your project.
$ python3 -m venv django_001_venv
$ source django_001_venv/bin/activate
Into this virtual environment named django_001_venv you will install django web framework.
pip install django
If you have problems with update pip then update this tool. Now start the django project named django_test.
$ django-admin startproject django_test
$ cd django_test
$ python3 manage.py runserver
Open the url http://127.0.0.1:8000/ with your web browser.
The result is this:

If you try to use the admin web with password and user you will see errors.
One of the most common problem for django come from settings, let's see some file from the project:

  • manage.py - this runs project specific tasks (the django-admin is used to execute system wide Django tasks) and is used to execute project specific tasks;
  • __init__.py - this file that allows Python packages to be imported from directories where it's present and it's a generic file used in almost all Python applications;
  • settings.py - the configuration settings for the Django project;
  • urls.py - contains URL patterns for the Django project; 
  • wsgi.py - is WSGI configuration properties for the Django project ( you don't need to setup WSGI to develop Django applications).

The next step is to create first django application.
$ python manage.py startapp django_blog
This make a folder named django_blog into the main django_test folder. Into the main django_test folder you have another django_test folder with settings.py file. Add into settings.py file the django_blog application.
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_blog',
]
Let's fix some issues about admin and the django_blog application.
Into the main django_test folder with manage.py file use this:
$ python3 manage.py migrate
$ python3 manage.py createsuperuser

This fix the django framework and let you to add your superuser using the admin page, see:

The next issue is: create the website ( see the django_blog folder) using the Django web framework.
I don't have a issue for this django_blog but you can follow this tutorial link.

Saturday, May 23, 2015

News: San Francisco Python Meetup Group ...

 ... Python Meetup is putting out a call for speakers:

Meet other local Python Programming Language enthusiasts! Please join us on the second Wednesday of each month for a Presentation Night of intermediate and advanced Python talks. Please join us on the third Wednesday of each month for a Project Night of Python tutorials, mentors helping new and intermediate Python developers, sprints on Python projects, and developers working on their own projects.

More about this www.meetup.com- sfpython.

Sunday, January 4, 2015

News: FOSDEM 2015 and python room.

FOSDEM is a free event that offers open source communities a place to meet, share ideas and collaborate. It is renowned for being highly developer-oriented and brings together 5000+ geeks from all over the world.
You can find a schedule of python room here.
The FOSDEM 2015 will take place at ULB Campus Solbosch on Saturday 31 January and Sunday 1 February 2015 - Brussels.
Also no registration necessary for this event, according to the FOSDEM website.

Thursday, September 18, 2014

News: Wing IDE 5.0.9 Released .

At September 10, 2014, the development team released the new version of Wing IDE.
See the details here: 5.0.9 - CHANGELOG.txt , also if you want to purchase licenses then you have this choice:

Wing IDE Pro:

Commercial Use
For companies, paid individuals, organizations, and government
Full-Featured Python IDE
Windows, Linux, and OS X
Includes One Year Support+Upgrades
Extend Support+Upgrades at $89/year
License is Transferable
$245 per user
$1150 5-pack

Non-Commercial Use
For students, educators, academic researchers, hobbyists, and publicly funded charities
Full-Featured Python IDE
Windows, Linux, and OS X
Optional Support+Upgrades at $89/year
$95 per user

Wing IDE Personal:
General Use
A low-cost alternative Python IDE for students and hobbyists
Omits Some Features
Windows, Linux, and OS X
Optional Support+Upgrades at $89/year
$45 per user