Python Forum
ImportError: No module named pymysql - On Apache2 for Python 2.7 on Mac
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError: No module named pymysql - On Apache2 for Python 2.7 on Mac
#5
(Jun-10-2019, 10:14 AM)Gribouillis Wrote:
Quote:it looks to be on the path (in console at least)
The question is whether it is also on the path when it runs in apache2. What's the result in that case?

Hi, Thanks

I think it must be missing from the apache2 path somehow…

Apache2 Error Log:

//With
import sys
raise RuntimeError(sys.path)
//


[Tue Jun 11 18:10:41.932500 2019] [cgi:error] [pid 7222] [client ::1:61557] AH01215: File "/Users/mapps/Sites/test.py", line 19, in <module>: /Users/mapps/Sites/test.py

[Tue Jun 11 18:10:41.932539 2019] [cgi:error] [pid 7222] [client ::1:61557] AH01215: raise RuntimeError(sys.path): /Users/mapps/Sites/test.py

[Tue Jun 11 18:10:41.933277 2019] [cgi:error] [pid 7222] [client ::1:61557]
AH01215: RuntimeError: ['/Users/mapps/Sites',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/Library/Python/2.7/site-packages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']:

/Users/mapps/Sites/test.py
[Tue Jun 11 18:10:41.936100 2019] [cgi:error] [pid 7222] [client ::1:61557] End of script output before headers: test.py


//adding before the sys path command terminates early
import pymysql
print(pymysql)
//



[Tue Jun 11 19:09:28.212921 2019] [cgi:error] [pid 7225] [client ::1:61683] AH01215: Traceback (most recent call last):: /Users/mapps/Sites/test.py
[Tue Jun 11 19:09:28.213230 2019] [cgi:error] [pid 7225] [client ::1:61683] AH01215: File "/Users/mapps/Sites/test.py", line 12, in <module>: /Users/mapps/Sites/test.py
[Tue Jun 11 19:09:28.213257 2019] [cgi:error] [pid 7225] [client ::1:61683] AH01215: import pymysql: /Users/mapps/Sites/test.py
[Tue Jun 11 19:09:28.213297 2019] [cgi:error] [pid 7225] [client ::1:61683] AH01215: ImportError: No module named pymysql: /Users/mapps/Sites/test.py
[Tue Jun 11 19:09:28.215094 2019] [cgi:error] [pid 7225] [client ::1:61683] End of script output before headers: test.py

(Jun-10-2019, 10:14 AM)Gribouillis Wrote: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7

In addition to this there is pymysql in the path but not as far as I can tell where it is expecting to see it: - I may have to copy it into the path somehow or add it in via the script..?

C-and-Ty:site-packages mapps$ pwd
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

C-and-Ty:site-packages mapps$ ls -d -- */
Django-1.11.20.dist-info/ mysqlx/
PyMySQL-0.9.3.dist-info/ pip-19.1.1.dist-info/
certifi-2019.3.9.dist-info/ pip/
certifi/ pkg_resources/
django/ protobuf-3.8.0.dist-info/
google/ pymysql/
mysql-vendor/ pytz-2018.9.dist-info/
mysql/ pytz/
mysql_connector-2.2.9-py2.7.egg-info/ setuptools-40.6.2.dist-info/
mysql_connector_python-8.0.16.dist-info/ setuptools/
mysql_connector_python_dd-2.0.2-py2.7.egg-info/ six-1.12.0.dist-info/
mysql_connector_repackaged-0.3.1-py2.7.egg-info/
Reply


Messages In This Thread
RE: ImportError: No module named pymysql - On Apache2 for Python 2.7 on Mac - by Tyrone - Jun-11-2019, 07:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 1,055 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 24,300 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,857 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,578 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,667 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,436 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 1,107 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 9,724 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 1,081 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,943 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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