Friday, May 3, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 3318  / 1 Year ago, sat, april 15, 2023, 4:42:15

I want tot use pygments in my python app.



At first, I installed pygments like this:



$sudo python setup.py install --prefix=/usr/local
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'include_package_data'
warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /usr/local/bin/pygmentize to 755
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/Pygments-1.4-py2.7.egg-info
Writing /usr/local/lib/python2.7/dist-packages/Pygments-1.4-py2.7.egg-info


After getting import error (ImportError: cannot import name highlight
) when trying to from pygments import highlight, and find out that there is a python-pygments package, I installed it from software center. Now it was installed in /usr/share/pyshared/pygments and there are symlinks in /usr/lib/python2.7/dist-packages/pygments point to that location which is much better then /usr/local/lib/python2.7/dist-packages with manual install.



But I keep getting ImportError.



What am I doing wrong?


More From » installation

 Answers
3

Do not name your script "pygments.py". Secondly if you did the above and consequently change the name of the script, you may still get an import error caused by the Byte-compiled python script called "pygments.pyc", you will need to change the name of the script and delete the old byte-compiled script called "pygments.pyc"


[#41304] Monday, April 17, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aveerakfas

Total Points: 106
Total Questions: 148
Total Answers: 129

Location: Monaco
Member since Sun, Jan 1, 2023
1 Year ago
;