openpyxl

11861
16
Jump to solution
01-10-2018 01:24 PM
CCWeedcontrol
Frequent Contributor

I have the following script, i am trying to export sql table to an excel file. I have installed  the openpyxl library using. C:\Python27\ArcGISx6410.4\Scripts>pip install openpyxl. everything installed fine. I have the following folders openpyxl & openpyxl-2.4.9.dist-info  in C:\Python27\ArcGIS1040\Lib\site-packages. Any ideas on what i am doing wrong?

When i runt he following script i get the error.

line 3, in <module>
import openpyxl
ImportError: No module named openpyxl

Script

import pyodbc
import pandas as pd
import openpyxl

cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=csde18;Trusted_Connection=yes', autocommit=True)

cursor = cnxn.cursor()
script = """
SELECT * FROM dbo.Characteristics 
"""

df = pd.read_sql(script, cnxn)

writer = pd.ExcelWriter('C:\\Temp\\Characteristics.xlsx')
df.to_excel(writer, sheet_name='bar')
writer.save()

print 'Done'
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
16 Replies
DanPatterson_Retired
MVP Emeritus

you did pip?  I don't use it, but I suspect there is a pip uninstall/remove or check in that python's distribution for 'uninstall' py or exe

0 Kudos
CCWeedcontrol
Frequent Contributor

I was able to uninstall it through the install/uninstall windows control panel, it was under Arcgis Background Geoprocessing 64 bit. I have removed the 64 bit, but know my IDLE is gone. How can i get IDLE back with 32 bit? I do have Pro installed but i currently now using it because i don't edit capabilities yet

0 Kudos
DanPatterson_Retired
MVP Emeritus

repair you install of arcmap through windows control panel install/uninstall then select repair

0 Kudos
CCWeedcontrol
Frequent Contributor

Ok, i removed the Arcgis Background Geoprocessing 64 bit and once i repair it and i deleted the ArcGISx6410.4 folder. Do i do an pip install openpyxl to the C:\python27\ArcGIS10.4\scrips - pip install openpyxl?

0 Kudos
DanPatterson_Retired
MVP Emeritus

My suggestion is to skip arcmap and install Pro, it is more accommodating and you will have your 64bit world

Nothing I have said has helped apparently, so I will let the other viewers of this post leap in to finish the task.

0 Kudos
CCWeedcontrol
Frequent Contributor

Dan, you have helped me.  i had to uninstall Arcmap and reinstall it. removal of the ArcMap Geoprocessing 64 bit corrupted my arcmap to where i could not uninstall. I had to use Microsofts Uninstall Troubleshooter https://support.microsoft.com/en-us/help/17588/fix-problems-that-block-programs-from-being-installed.... Once i ran this i was able to uninstall arcmap, reinstalled and now i have python 32 bit and idle. After add some libraries (pyodbc & openpxyl) i was able to get past the error. but now i have another error ha ha.

thank you.

DanPatterson_Retired
MVP Emeritus

proof from pro...

0 Kudos