PythonSponsored by Jamf Now

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.

Share tech news, updates, or what's on your mind.

Sign up to Post


error: Cannot find cmake, ensure it is installed and in the path

How do I fix that problem?

Free Tool: Path Explorer
LVL 12
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


i get an error:

anaconda-client 1.6.14 has requirement python-dateutil>=2.6.1, but you'll have python-dateutil 2.6.0 which is incompatible

how do i fix that problem?

OSError: `pydot` failed to call GraphViz.Please install GraphViz ( and ensure that its executables are in the $PATH.

I am not able to call GraphViz with pyplot. I tried various references on github, video but it does not to work out for me.

My Problem refers exactly like this one stated below:

I have installed the pydot through pip
installed msi file of Graphviz from this link -

I have given the path of executables of pydot and graphviz in user variable and system variable also.
I am attaching the snapshot also.
My pydot

I'm new to Python but using it to try to pull data from a XML file.  The XML file is not consistent so my code is breaking and I would like to handle the error.  How can I change my code below so that if an attribute does not exist for a given record in my XML it just ignores it and return an empty string into my variable?

XML (note that the "MonitorVersion" attribute does not exist for all records as it is is optional) :

<?xml version="1.0" encoding="UTF-8"?>

<myData locale="en_US">
 <Me Name="Bob" Age="50"/>
 <Record HealthDataType="HeartRate" sourceName="HeartMonitor" ValueData="66" />
 <Record HealthDataType="SleepHours" sourceName="SleepMonitor" [i]MonitorVersion[/i]="1" ValueData="9"/>

Open in new window

My Code (note that the code breaks when trying to populate the variable "y"

import xml.sax

class MovieHandler( xml.sax.ContentHandler ):

	# Call when an element starts
	def startElement(self, tag, attributes):

		self.CurrentData = tag

		if tag == "Record":         
			# This works
			x = attributes["HealthDataType"]

			# This does NOT work as this attribute is not present in each record
			y = attributes["MonitorVersion"]

def main():
  	# create an XMLReader
	parser = xml.sax.make_parser()
	# turn off namepsaces
	parser.setFeature(xml.sax.handler.feature_namespaces, 0)

	# override the default ContextHandler
	Handler = MovieHandler()
	parser.setContentHandler( Handler )


if __name__ == "__main__":


Open in new window

from fpdf import FPDF
  import multiprocessing
  from multiprocessing import Pool

  class pdf_gen():
    def __init__(self):
      pdf = self.pdf = FPDF()

    def get_data_from_mysql(self) :
      pdf = self.pdf
      # connection is established and result is stored in 'res'.
      dup = []
      z = tuple(dup)
      return z

    def mysql_to_pdf_data(self,*result) :
      try :
        pdf = self.pdf
        # Entered data need to be in pdf
        return pdf

  if __name__ == "__main__" :
   class_pdf_object = pdf_gen()
   pdf_object = FPDF()
   recover_data = class_pdf_object.get_data_from_mysql()
   pool = multiprocessing.Pool(multiprocessing_count())
   pdf =,recover_data)

In the above program, pdf_object is creating empty pdf file as the object in class needs to be passed for output. But, recover_data contains a list and each value is passing and returning different objects and need to be merged and give single pyfpdf object and passed it to output function of pyfpdf. Any help would be appreciated. I know it can be done with the help pdf_object('savefile.pdf','S').
I am trying to use LDAP Authentication in Python Flask.

Here's my test page, taken from SimpleLDAP official documentation:

    from flask import Flask, g, request, session, redirect, url_for
    from flask_simpleldap import LDAP
    app = Flask(__name__)
    app.secret_key = 'dev key'
    app.debug = True
    #app.config['LDAP_USE_SSL'] = True
    app.config['LDAP_HOST'] = 'my-dc-server'
    app.config['LDAP_BASE_DN'] = 'OU=-my-ou,dc=my,dc=domain,dc=com'
    app.config['LDAP_USERNAME'] = 'CN=my-domain-admin-working-user,OU=my-ou,DC=my,DC=domain,DC=com'
    app.config['LDAP_PASSWORD'] = 'my-domain-admin-working-password'
    ldap = LDAP(app)
    def index():
        return 'Welcome, {0}!'.format(g.ldap_username)
    if __name__ == '__main__':
        app.debug = True'', port=8000)

Open in new window

If I input a working domain user into the popup I always get:

    Traceback (most recent call last):
      File "/home/ubuntu/ipcatalogue_env/lib/python3.5/site-packages/flask/", line 2309, in __call__
        return self.wsgi_app(environ, start_response)
      File "/home/ubuntu/ipcatalogue_env/lib/python3.5/site-packages/flask/", line 2295, in wsgi_app
        response = self.handle_exception(e)
      File "/home/ubuntu/ipcatalogue_env/lib/python3.5/site-packages/flask/", line 1741, in handle_exception
        reraise(exc_type, exc_value, tb)

Open in new window

i am a java developer.
planning to learn some machine learning. so thought i should start learning python.
whats the best way...
please suggest some books/ videos / lectures etc...

Facing error when trying to execute a python script in Jenkins:

 File "C:\WINDOWS\TEMP\", line 8, in <module>
    cellName = AdminControl.getCell()
NameError: name 'AdminControl' is not defined
Build step 'Execute Python script' marked build as failure
Finished: FAILURE
It's the first time for me to do programming in any language, so please understand that my poor code.

So I was trying to place 10-elements shared list, and sort and check the elapsed time of it with 10 subprocesses.

I tried to make the list in global, or share the list with the Manager() inside of the Multiprocessing.

I tried but I had an error that says "name 'initlist' is not defined" or no output list printed in the console at all.

What would be the problem of it?
It's okay just to answer with one problem between those two problems.

By the way, I'm using python 3.6, just in case..

Here is the code with the global list :
	# coding: utf-8

	import timeit
	import multiprocessing
	import random
	import time

	initlist = []

	def control(lock, i):
		global initlist
		run = timeit.timeit('initlist.sort()', number=1)
		print('\n[{0}] --> '.format(i), end=" ")
		for z in initlist:
			print(z, end=" ")

	if __name__ ==  '__main__':

		for x in range(0,10):

		print('#### Sorting with List')
		for y in initlist:
			print('{0}'.format(y), end=" ")

		lock = multiprocessing.Lock()

		for x in range(0,10):
			print('#### Process #{0} started ...'.format(x))
			process = multiprocessing.Process(target=control, args=(lock, x))


Open in new window

and this is the code with shared list using manager():

Open in new window

Disclaimer : I am writing my first Python script so please do not laugh at my questions : )

I want to write an insert statement and here is what i have. if someone can show me correct syntax

with open('somefile.csv') as csvfile:
    readCSV = csv.reader(csvfile, delimiter='|')
    for row in readCSV:

insert into table1 (Column1, Column2, Column3, Column4) Values ( I need values from these variables row[0],row[1],row[3].strip("0"),row[15],row[32])
Get expert help—faster!
LVL 12
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

For a project I have a  Python PyQT4  application in full screen mode that is running on Windows 10.

This application has now to take photos.

Ideally the Photo  application would be a widget in pyqt and we could therefore design the layout (img size / exposure / flash / take picture buttons / etc), but it's also OK to use another full screen application, that could be started via subprocess.Popen().

The application would ideally be able to choose the image resolution, exposure, framerate of viewer window but it's also OK to take picture always with the highest resolution and to perform the downscaling afterwards.

Any suggestions of how to do this best?
Hi Guys,

I have a small Python program running on windows 10:
This program observes and configures the wireless mobile access (mobile broadband) of the tablet it's running on.

This means:
- detect whether the SIM card is inserted.
- extract the EMEI, operator id, etc
- configure the APN, user and password
- check whether the mobile network is up or down

At the moment I have a solution using ctypes and a custom DLL, written by somebody who left the company many years ago.
Now this solution fails to work with a new tablet and certain SIM cards (Windows 10 itself has no problem using this tablet and this particular SIM card)

Therefore I wonder if there's any solution to  achieve above mentioned tasks with any of below:
- python ctypes
- win32 lib
- netsh
- powershell
- a cool command line tool with a permissive license
- .bat
- or anything else, that does not require Installation of Visualstudio or SDKs.

I would like to avoid anything that requires Visual Studio for compilation, as this is  rather complex  for long term maintenance. (Trying to recompile some old C code years later is sometimes tricky. and having to install the whole build environment on a tablet or having to build on a dedicated build host is something I'd like to avoid.

Thanks in advance for any pointers / ideas
i have run this code but when i click on submit button the table stored with (self.firstName,self.lastName) not with the entered names by entry text box
Hello, today I encountered this strange problem.
if dontshowagain == 'd':
    file = open("statistics","a")

Open in new window

To me this seems perfectly fine, but Python says, that there is a syntax error and invalid syntax. It also highlights ":" I really don't understand why.

I need to get the values of attributes of VMM config for WebSphere Application Server 8.5.5 ND cells. Looking in the wimconfig.xml file, I can see the attributes/values needed, but no corresponding config types/IDs. The attributes don't map to AdminConfig object types, so the showAttribute command can't be used.

For example:

    <config:repositories xsi:type="config:FileRepositoryType" adapterClassName="" id="InternalFileRepository" supportPaging="false" messageDigestAlgorithm="SHA-1">
       <config:baseEntries name="o=defaultWIMFileBasedRealm"/>
     <config:repositories xsi:type="config:LdapRepositoryType" adapterClassName="" id="USER_REPO" isExtIdUnique="true" supportAsyncMode="false" supportExternalName="false" supportPaging="false" supportSorting="false" supportTransactions="false" supportChangeLog="none" certificateFilter="" certificateMapMode="exactdn" ldapServerType="AD" translateRDN="false">
       <config:baseEntries name="o=USER_REPOAA" nameInRepository="DC=example,DC=domain,DC=com"/>
       <config:ldapServerConfiguration primaryServerQueryTimeInterval="15" returnToPrimaryServer="true" sslConfiguration="CellDefaultSSLSettings">
         <config:ldapServers authentication="simple" bindDN="CN=BIND001, OU=Bind Accounts, OU=Admin Accounts, OU=Middleware, DC=example, DC=domain, …
Hello, I wanted to continue with my pyautogui project detecting, where the mouse is and I wanted  for example to make people on my computer doing only things,that I want them to do, by limting their access to the bottom bar on windows. I used Python 3.6.5. Here is my code:
if hedgehog == 1:
   import pyautogui
   import time
   while True:
       position = pyautogui.position()
       screensize = pyautogui.size
       height, width = screensize
       x, y = position
       bottomlimit = width - 43 
       if y == bottomlimit:

Open in new window

When I want to run this code , it says. height, width = screensize  
TypeError: 'function' object is not iterable
When replaced that line with: height, width = pyautogui.size ,it gave me the same error.
Hello, I wanted to make a simple program that could count how old a person using it is, according to his/her birthday and datetime module. import datetime
now =
    if day == and month == now.month:
         age = now.year - year
    if day != or  month != now.month:
         age  = now.year - age - 1
    if now.year - year  == -1:
        print("Be serious, please.")
    if now.year - rok < -1:
        print("Be serious,please.")

Open in new window

I did this according to tutorials I found on the Internet, but when I want to run this piece of code, it says this: AttributeError: module 'datetime' has no attribute 'now' This project's purpose is only to show approximate age of people,so just the basics.
How to write this code correctly?
First I would like to say, I am a notice when it comes to Linux, So treat me gently and Explain your answers in great detail:

I have a zabbix monitoring server in place on CentOS 7 that I would like schedule run times on as the server Database is getting extremely large very fast.

What is the best way to accomplish this.

I have read about using Crontab to run a .sh script, however, I don't know the first thing about this process.

Those familiar with Zabbix, is there a "setting" that I can incorporate to limit the collections to only certain times of the day?
Hello, I recently started making programs in Python using pyautogui. Here is some of my code:
import pyautogui
while True:
    position = pyautogui.position()
    x = position[0:3]
    y = position[-3:]

Open in new window

But when I run the code it only prints a variable called  position two times on one line.
What should I do to print two independent variables? One holding the value of the first three digits of the variable position and the second one the last three digits of the variable position.
Introducing Cloud Class® training courses
LVL 12
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Hello, I need your advice in which program can i accomplish the following either with C# or Python.
I am a Sys Admin working for a DevOps environment.

We have QA, UAT and PROD environments.
100% of the the time we need to help developers in Copying, Pasting  From / To, Starting a service, Stopping a service and Recycling an app pool in IIS.
But in PROD night, we are done around 8pm, 1hr approx which includes: Copying, Pasting  From / To, Starting a service, Stopping a service and Recycling an app pool in IIS then we have to wait, wait wait and wait if the developers find any issues in PROD and they need the Sys Admin help for Copying, Pasting  From / To, Starting a service, Stopping a service and Recycling an app pool in IIS.

It was my first time that I experienced that and I said: Damn, the whole Copying, Pasting  From / To, Starting a service, Stopping a service and Recycling an app pool in IIS can done programmatically and we do not need to wait till midnight or so if Developers need a SysAdmin, in other words i can try to develop an executable that can do the following:

Which environment are you working: QA, UAT, PROD
Servers are listed: 1, 2, 3, 4
Which windows service are you going to work ? (List of services)
Browse the source, Get the file,.
Need to stop the service (Yes/No)
Browse to the target ? Place
This server has the following App Pools (List of the App Pools)
Do they need to be recycle ?

Thoughts ? Thanks for your help
How to protect and unprotect the excel sheet?
how rfid reader read uhf rfid tag using python language.........plz help mi
Hi experts,

I get bad gateway request.  I use nginx, uwsgi docker wagtail application.  Please find attached nginx.ini and uwsgi.ini  I am running all inside a docker containers.

nginx settings

user www-data;
worker_processes auto;
pid /run/;

events {
        worker_connections 768;
        # multi_accept on;

http {

        # Basic Settings

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        # SSL Settings

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        # Logging Settings

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        # Gzip Settings

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        # Virtual Host Configs


Open in new window

import mysql.connector
from mysql.connector import Error
import os

db = mysql.connector.connect(host='localhost',database='mysql', user='root',password='admin@123')
cursor = db.cursor()

for root, dirs, files in os.walk('music'):
    # pref = ''
    head, tail = os.path.split(root)
    while head:
        # pref +='  '
        head, _tail = os.path.split(head)
      fname = os.path.join(tail)
      cursor.execute("INSERT INTO category(name,parent_id) VALUES('" + fname + "',1)")

for f in dirs:
      print (f)

| category_id | name     | parent_id |
|           1 | rxl      |         1 |
|           2 | jazz     |         1 |
|           3 | del      |         1 |
|           4 | del      |         1 |
|           5 | mum      |         1 |
|           6 | mum      |         1 |
|           7 | jmv      |         1 |
|           8 | jmv      |         1 |
|           9 | jmv      |         1 |
|          10 | hip hop  |         1 |
|          11 | kol      |         1 |
|          12 | kol      |         1 |
|          13 | bang     |         1 |
|          14 | bang     |         1 |
|          15 | hyd      |         1 |
|          16 | hyd      |         1 |
|          17 | pop      |         1 |
inserting dirs/subdir/files to mysql from python with parent parent =music …
When I try to run the below script as python3.6 4 -v 1, I just get the value of the answer but not the output of print ("{}^2 == {}".format (args.square, answer)). Same thing with a value of 2


import argparse
parser = argparse.ArgumentParser()
parser.add_argument("square", type=int, help="display a square of a given number")
parser.add_argument("-v", "--verbosity",help="increase verbosity output")
args = parser.parse_args()
answer = args.square**2
if args.verbosity == 2:
    print("the square of {} equals {}".format(args.square, answer))
elif args.verbosity == 1:
    print ("{}^2 == {}".format (args.square, answer))

PythonSponsored by Jamf Now

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.