简体   繁体   中英

error while executing python script from php

i have published my website using python-php mysql hosting server. Now they told me to create an virtualenv after that i was able to install my required packages like pypi newspaper. My python scripts are totally dependent on pypi newspaper.

Now the issue is that when i call my index.php from publi_html and call my python script it shows me following error:

Traceback (most recent call last):" [1]=> string(79) " File "/home/adpnewsi/public_html/adpScripts/getImage.py", line 3, in " [2]=> string(33) " from newspaper import Article" [3]=> string(38) "ImportError: No module named newspaper" }

You are probably not using the virtual python environment. In your terminal type which python . If the output is /usr/bin/python you need to switch to your virtual environment.

Go to the directory where you created your virtualenv and in terminal enter source bin/activate . Then use which python to verify your are now using your virtual environment to run the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM