I am trying to run a php script that will call a python script that calls imaplib to pull some files from my email. When I run the python script standalone in vscode (bash terminal), it works as designed. When I run the PHP script that calls the python script, the following error is produced.
Traceback (most recent call last):
File "C:/xampp/htdocs/report/pythonfile/parse_script_og.py", line 43, in <module>
mail = imaplib.IMAP4_SSL('imap.googlemail.com')
AttributeError: module 'imaplib' has no attribute 'IMAP4_SSL'
As a test, I echoed out the command and pasted it into Git Bash. The files were pulled and added to the folder specified. When I pasted the command into CMD, the error above was produced. What settings am I missing?
I am using XAMPP, VSCode, PHP 7.3.4, Python 3.7.1
From recommendation below I added "import ssl" to my python script, I received the following error:
"Traceback (most recent call last):"
" File "C:/xampp/htdocs/report/pythonfile/parse_script_og.py", line 2, in <module>"
" import ssl"
" File "C:\Users\Garrett\Anaconda3\envs\snowflakes\lib\ssl.py", line 98, in <module>"
" import _ssl # if we can't import it, let the error propagate"
"ImportError: DLL load failed: The specified module could not be found."
so then I went to my python environment, and tried to "pip install ssl" and I got the following error.
(snowflakes) C:\Users\Garrett>pip install ssl
Collecting ssl
Using cached https://files.pythonhosted.org/packages/83/21/f469c9923235f8c36d5fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Garrett\AppData\Local\Temp\pip-install-abzxmk8x\ssl\setup.py", line 33
print 'looking for', f
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\Garrett\AppData\Local\Temp\pip-install-abzxmk8x\ssl\
(snowflakes) C:\Users\Garrett>
Another Update
The following command is what is executed in PHP (exec()). The input folder will contain files pulled from email. The output folder will contain a singular file created from the files pulled from email. If I paste this command into GitBash, everything works as planned. If I paste the following command into CMD, I get the error shown above.
C:/Users/Garrett/Anaconda3/python.exe C:/xampp/htdocs/report/pythonfile/parse_script_og.py C:/xampp/htdocs/report/input/ C:/xampp/htdocs/report/output/out.csv John Doe 06-Jan-2018 16-Jan-2019