Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:16:15+00:00 2026-06-14T04:16:15+00:00

I am encountering a small hiccup in the installer I am creating in python.

  • 0

I am encountering a small hiccup in the installer I am creating in python. I have a function which returns the value of a key based on it’s location.

def CheckRegistryKey(registryConnection, location, softwareName, keyName):
'''
Check the windows registry and return the key value based on location and keyname
'''    
    try:
        if registryConnection == "machine":
            aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
        elif registryConnection == "user":
            aReg = ConnectRegistry(None,HKEY_CURRENT_USER)   
        aKey = OpenKey(aReg, location)
    except Exception, ex:
        print ex
        return False

    try:
        aSubKey=OpenKey(aKey,softwareName)
        val=QueryValueEx(aSubKey, keyName)
        return val
    except EnvironmentError:
        pass

I get an error if the location does not exist. I want the function to return False so if the location does not exist so I can run the software installer, bit it always lands up in the exception

# check if the machine has .VC++ 2010 Redistributables and install it if needed
try:
    hasRegistryKey = (edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed"))
    if hasRegistryKey != False:
        keyCheck = (edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed"))[0]
        if keyCheck == 1:   
            print 'vc++ 2010 redist installed'
    else:
        print 'installing VC++ 2010 Redistributables'
        os.system(productsExecutables + 'vcredist_x86.exe /q /norestart')
        print 'VC++ 2010 Redistributables installed'
except Exception, ex:
    print ex

The exception I get when I run the code is

'NoneType' object has no attribute '___getitem___'

and the error I get from the def CheckRegistryKey function is

[Error 2] The system cannot find the file specified

What I need to do is check if the registry key or location exists, if not direct it to an executable. Any help is appreciated.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:16:16+00:00Added an answer on June 14, 2026 at 4:16 am

    The reason for the error:

    'NoneType' object has no attribute '___getitem___'
    

    Is in the line:

    keyCheck = (edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed"))[0]
    

    The fragment edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed") is returning None.

    This means you end up with:

    keyCheck = (None)[0]
    

    This is what is throwing your error. You are trying to get an item on a object that is None.

    The reason that this you are getting None back from your CheckRegistryKey function is that if an error occurs you aren’t returning anything. You need to return False when you catch a EnvironmentError:

    try:
        aSubKey=OpenKey(aKey,softwareName)
        val=QueryValueEx(aSubKey, keyName)
        return val
    except EnvironmentError:
        return False
    

    I would also modify your code so that you are only calling CheckRegistryKey once:

    registryKey = edit_registry.CheckRegistryKey("machine", r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist", "x86", "Installed")
    if registryKey is not False:
        keyCheck = registryKey[0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a system that turns a small script into a dll. I'm encountering
I have a small web app for reporting and im encountering problems with it.
I'm encountering a strange issue, where sqlsrv_query() returns a valid statement resource, but sqlsrv_fetch_array()
I've been encountering an OverflowException recently within GDI+ via a 3rd party tool which
I have a Solaris sparc (64-bit) server, which has 16 GB of memory. There
I have a small WCF hosting engine that I am writing that will dynamically
I have a question about the SQL standard which I'm hoping a SQL language
I'm encountering the following error at unpredictable times in a linux-based (arm) communications application:
I am encountering a problem with codeigniter and JQuery Ajax Post. My javscript $('.remove').click(function(){
I'm encountering what seems like quite surprising performance differences when iterating over a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.