Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel/python issue
#1
Big Grin 
Hi everyone, I've just started to work with excel using python. I downloaded 'openpyxl' package and when i import openpyxl, there are some errors such as: SyntaxError: Invalid syntax
this is my very simple code:
import openpyxl
But when I run it, it got some errors.
https://megabackup.com/g/piix
I wonder if there is any errors in openpyxl package which I downloaded.
Reply
#2
You shall not download anything to install to Python(just in some special cases),this was the old and broken past Wink
All is done with pip.
Quick demo:
C:\code
λ python -V
Python 3.7.0

# This is a test that pip work from cmd as it should
C:\code
λ pip -V
pip 10.0.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Install all is done automatic
C:\code
λ pip install openpyxl
Collecting openpyxl
  Downloading https://files.pythonhosted.org/packages/f6/13/3c1263b852377738eaa60f99602fb58cc8ad2fd1badb0b724b0d5b532727/openpyxl-2.5.4.tar.gz (170kB)
    100% |████████████████████████████████| 174kB 1.6MB/s
Collecting jdcal (from openpyxl)
  Downloading https://files.pythonhosted.org/packages/a0/38/dcf83532480f25284f3ef13f8ed63e03c58a65c9d3ba2a6a894ed9497207/jdcal-1.4-py2.py3-none-any.whl
Collecting et_xmlfile (from openpyxl)
  Downloading https://files.pythonhosted.org/packages/22/28/a99c42aea746e18382ad9fb36f64c1c1f04216f41797f2f0fa567da11388/et_xmlfile-1.0.1.tar.gz
Installing collected packages: jdcal, et-xmlfile, openpyxl
  Running setup.py install for et-xmlfile ... done
  Running setup.py install for openpyxl ... done
Successfully installed et-xmlfile-1.0.1 jdcal-1.4 openpyxl-2.5.4

# Test that it work
C:\code
λ python
>>> import openpyxl
>>> openpyxl.__version__
'2.5.4'
I use cmder here,but command is exactly the same in cmd.
Problem with installation and pip look at Python 3.6/3.7 and pip installation under Windows
Reply
#3
Your python version is the problem.
Python 3 didn't support explicit unicode literals prior to 3.3.
That said, there is probably no good reason anyone should be using 3.2, just update to 3.7.
Reply
#4
Thanks so much guys, now I know how to solve my problem.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020