microsoft / PTVS

Python Tools for Visual Studio
https://aka.ms/PTVS
Apache License 2.0
2.52k stars 676 forks source link

Error 'Exception Thrown' : 'No Module Found Pyodbc' #6581

Closed vsfeedback closed 3 years ago

vsfeedback commented 3 years ago

This issue has been moved from a ticket on Developer Community.


I receive the error titled when running Microsoft VS 2019 16.10.2 I am running Windows 10 21H1 19043.1055. I am running Python 3.7 with IDLE. The program is installed here: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64 The user folder is: C:\Users\salag\AppData\Roaming\Python\Python37\site-packages

I needed a conn function from Python Pyodbc. I attempted to install Pyodbc from cmd with: 'pip install pyodbc.' The system said that the requirement was already met and pyodbc was already installed.

I made sure that this package showed under Python 3.7. Yet, when I run my program, I get the error titled above.

Of course, the exception error is thrown on "import pyodbc" line right at the top of the script.

Here is the full script:

import pyodbc

This function establishes a connection between Python and Microsoft SQL

server.

def dbconnection():

conn = pyodbc.connect("Driver={SQL Server Native Client 11.0};" "Server=SURESH;" "Database=SQL Tutorial;" "username = dbusertest" "password = THIS WILL NEED TO BE DONE BY CLIENT CERTIFICATE;" "Trusted_Connection=yes;")

cursor = conn.cursor() cursor.execute('SELECT * FROM Employ')

for row in cursor: print('row = %r' % (row,))

def main():

dbconnection()

print("Welcome to the IT Security Team Knowledge Base.") print("The Knowledge Base will outline the people and resources") print("that are available to the team.") print()

people()

print("Congratulations. You entered an application called: ", a3.name)

print()

apps_list = ["Cisco FirePower", "Cisco AMP", "Cisco Threat Response", "Cisco Orbital",

#             "ManageEngine AD Audit", "ManageEngine AD Manager", "Forcepoint EMail Security",
#             "Forcepoint Web Security", "Forcepoint DLP Security", "DUO"]

apps_list.sort()

#print(apps_list)
#print()

applications()

print("You have stopped entering input. Exiting.")

def people(): print("The IT Security/IT Access Team members are:") print() people_list = ["Thomas Boilek", "Samantha Nikel", "Daniel Heffernan", "Scott Lagger", "Fabian Cambron", "Michael Krohn", "Olu Adeleke", "David Dinkel"] people_list.sort() print(people_list)

def applications(): print("The IT Security Team Applications are:") print() class Applications: def init(self, name, version, deliveryapp, vendor, vendor_contact, vendor_contact_phone, vendor_contact_email, owner_contact, owner_contact_phone, owner_contact_email, serverHostName, serverIPAddress, start_Date, end_Date, decommission_Date): self.name = name self.version = version self.deliveryapp = deliveryapp self.vendor = vendor self.vendor_contact = vendor_contact self.vendor_contact_phone = vendor_contact_phone self.vendor_contact_email = vendor_contact_email self.owner_contact = owner_contact self.owner_contact_phone = owner_contact_phone self.owner_contact_email = owner_contact_email self.serverHostName = serverHostName self.serverIPAddress = serverIPAddress self.start_Date = start_Date self.end_Date = end_Date self.decommission_Date = decommission_Date

a1 = Applications("Cisco FirePower", "45.71", "pass", "Cisco", "Erin Rogers","312-817-2333", @yyy, "Konrad Mikolajczyk", "630-527-5142", @yyy, "EEHFIREPWR01", "10.10.0.21", "2-15-1981", "pass", "pass")

print(a1.name) print(a1.version) print(a1.deliveryapp) print(a1.vendor) print(a1.vendor_contact) print(a1.vendor_contact_phone) print(a1.vendor_contact_email) print(a1.owner_contact) print(a1.owner_contact_phone) print(a1.owner_contact_email) print(a1.serverHostName) print(a1.serverIPAddress) print(a1.start_Date) print(a1.end_Date) print(a1.decommission_Date) print()

a2 = Applications("Cisco AMP", "12.56", "pass", "Cisco", "Erin Rogers", "312-817-2333", @yyy, "Konrad Mikolajczyk", "630-527-5142", @yyy, "EEHAMP01", "10.10.0.34", "2-15-2013", "pass", "pass")

print(a2.name) print(a2.version) print(a2.vendor_contact) print(a2.vendor_contact_phone) print(a2.vendor_contact_email) print(a2.owner_contact) print(a2.owner_contact_phone) print(a2.owner_contact_email) print(a2.serverHostName) print(a2.serverIPAddress) print(a2.start_Date) print(a2.end_Date) print(a2.decommission_Date) print()

a3 = Applications

response = 'Y' while response == 'Y' or response == 'y':

response = input("Do you want to enter an application into the program?: ") print()

a3.name = input("Please enter the name of the application: ") a3.version = input("Please enter the application version: ") a3.deliveryapp = input('Please type "citrix" if this application is citrix delivered: ') a3.vendor = input("Please enter the vendor name of the application: ") a3.vendor_contact = input("Please enter the vendor's contact's name: ") a3.vendor_contact_phone = input("Please enter the vendor's phone number: ") a3.vendor_contact_email = input("Please enter the vendor's email: ") a3.owner_contact = input("Please enter the system owner's name: ") a3.owner_contact_phone = input("Please enter the system owner's phone number: ") a3.owner_contact_email = input("Please enter the system's owner's email: ") a3.serverHostName = input("Please enter the server's hostname: ") a3.serverIPAddress = input("Please enter the server's IP address: ") a3.start_Date = input("Please enter the start date of the application in (XX-XX-XXXX) format: ") a3.end_Date = input("Please enter the end date of the application in (XX-XX-XXXX) format: ") a3.decomission_Date = input("Please enter the decommission date of the application in (XX-XX-XXXX) format: ") response = input("Do you want to continue? ")

main()

I have read countless online pages on the install of this module, and I followed them exactly. Can't figure out where to go from here.

Thanks, Scott L.


Original Comments

Feedback Bot on 6/23/2021, 10:53 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

salagger07 commented 3 years ago

You may close this issue. I uninstalled the Python 3.8 including IDLE that I had installed manually. I then reinstalled the Python interpreter in VS. After a reboot, the pyodbc package worked fine in VS.