virtualenv中解决报错:ImportError: No module named time

其中:2env为使用virtualenv创建的虚拟环境,xxx.py为我要运行的python程序

(2env) [root@xxxx]$ /gunicorn  xxx.py
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
File "/xxxx/env/bin/gunicorn", line 5, in <module>
from pkg_resources import load_entry_point
File "/xxx/env/lib/python2.7/site-packages/pkg_resources.py", line 16, in <module>
import sys, os, time, re, imp, types, zipfile, zipimport
ImportError: No module named time

解决办法:
将可正常运行同样程序机器下目录/xxxx/2env/lib/python2.7/site-packages目录下的两个文件夹
pip和pkg_resources打包压缩,拷贝到目标机器同样的目录下解压,

再次执行你的程序:/gunicorn  xxx.py  可正常执行

posted @ 2020-07-01 19:44  天地一体  阅读(1938)  评论(0编辑  收藏  举报