简体   繁体   English

共享服务器:在UNIX Shell和HTTP下运行的Python脚本

[英]Shared Server: Python Script run under UNIX Shell vs HTTP

I have a Python script on my Dreamhost shared server. 我的Dreamhost共享服务器上有一个Python脚本。 When I access my script via SSH (using the UNIX Shell) my script executes fine and is able to import the Pycrypto module Crypto.Cipher . 当我通过SSH(使用UNIX Shell)访问脚本时,我的脚本执行得很好,并且能够导入Pycrypto模块Crypto.Cipher

But if I access my script via HTTP using my websites url. 但是,如果我使用网站网址通过HTTP访问脚本。 The script fails when it goes to import the Pycrypto module Crypto.Cipher . 该脚本在导入Pycrypto模块Crypto.Cipher It gives the error ImportError: No module named Crypto.Cipher . 它给出错误ImportError: No module named Crypto.Cipher

Do you know what might be causing this weird error? 您知道什么可能导致此奇怪的错误吗? And how I can fix it. 以及我该如何解决。

Some important information: 一些重要信息:
- I have installed a custom version of python on my shared server. -我在共享服务器上安装了自定义版本的python。 Its just Python 2.7 with Pycrypto and easy_install installed. 它只是安装了Pycrypto和easy_install的Python 2.7。
- I am certain that the script is running under Python 2.7 and not Dreamhosts default 2.6 version. -我确定该脚本在Python 2.7下运行,而不是Dreamhosts的默认2.6版本。 I know this because the script prints sys.version_info(major=2, minor=7, micro=0, releaselevel='final', serial=0) both in the UNIX shell and HTTP. 我知道这一点是因为该脚本在UNIX Shell和HTTP中都打印sys.version_info(major=2, minor=7, micro=0, releaselevel='final', serial=0)
- I installed Pycrypto manually (using tar, and running setup.py) as opposed to using easy_install or pip. -我手动安装了Pycrypto(使用tar,并运行setup.py),而不是使用easy_install或pip。
- I have editted my .bash_profile's PATH variable correctly (well I believe I have done it correctly because the script is run under Python 2.7 not 2.6). -我已经正确编辑了.bash_profile的PATH变量(好吧,我相信我已经正确完成了,因为脚本是在Python 2.7而非2.6下运行的)。

Any advice would be extremely helpful. 任何建议都将非常有帮助。

您的Web服务器未读取.bash_profile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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