EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: 答复: Question about "import MySQLdb" module problem in CSS python script
From: lzf neu <[email protected]>
To: Matt Newville <[email protected]>, "[email protected]" <[email protected]>
Date: Sun, 18 Sep 2016 17:39:49 +0000

hi,
Thanks for your reply! 
_mysql.so already included in the path I filled in the PYTHONPATH, but the problem still exists.
Thank you all the same.

发件人: [email protected] <[email protected]> 代表 Matt Newville <[email protected]>
发送时间: 2016年9月18日 14:19:08
收件人: lzf neu
抄送: [email protected]
主题: Re: Question about "import MySQLdb" module problem in CSS python script
 
Hi,

On Sun, Sep 18, 2016 at 7:56 AM, lzf neu <[email protected]> wrote:

Hi all,


  I want to import MySQLdb module in CSS to operate the mysql database.


  In order to do this, I have looked up the CSS manual and add the MySQLdb module path ("/usr/lib64/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/") in the PYTHONPATH that obtained from sys.path;

 

  The content of python script that I wrote only contain two lines:


  from org.csstudio.opibuilder.scriptUtil import PVUtil
  import MySQLdb

  however, when running the python script in CSS, an error occured and print out the following message:


  Traceback (most recent call last):

  File "<script>", line 2, in <module>
  File "/usr/lib64/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/MySQLdb/__init__.py", line 19, in <module>
  File "/usr/lib64/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py", line 7, in <module>
  File "/usr/lib64/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py", line 6, in __bootstrap__
  ImportError: No module named _mysql

 

  If I import MySQLdb module directly in python terminal window and everything is OK and no error occurred !


  Any help will be appreciated and thanks in advance !


Zhefu


I have no experience with CSS, so this is a guess:  I would suspect that there is a _mysql.so file in /usr/lib64/python2.7/site-packages.  At least, that's how I remember MySQLdb.py working.   If it's not there, it has to be somewhere closeby.

If you had to explicitly set PYTHONPATH for the import of  MySQLdb to work in CSS, you might need to include the directory that contains _mysql.so in PYTHONPATH too.

Hope that helps,

--Matt Newville

References:
Question about "import MySQLdb" module problem in CSS python script lzf neu
Re: Question about "import MySQLdb" module problem in CSS python script Matt Newville

Navigate by Date:
Prev: 答复: Question about "import MySQLdb" module problem in CSS python script lzf neu
Next: device support for Leica lasertracker Peter . Mueller
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Question about "import MySQLdb" module problem in CSS python script Matt Newville
Next: Re: Question about "import MySQLdb" module problem in CSS python script Kasemir, Kay
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 19 Sep 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·