码迷,mamicode.com
首页 > 编程语言 > 详细

virtualenv中执行python脚本报错ImportError: No module named markupsafe 或 No such file or directory: '/tmp/tmp0lEZD9/lib/python'

时间:2020-07-01 20:37:26      阅读:58      评论:0      收藏:0      [点我收藏+]

标签:nbsp   template   env   cep   nod   targe   des   list   使用   

2env为我使用virtualen创建的虚拟python环境,我的本地要使用的各类库已下载到文件夹lianxi下面,ceshi2.txt为我要安装的各类库包列表

(2env) [root@xxxxxxx]$ ./2env/bin/python wsgi.py
Traceback (most recent call last):
File "wsgi.py", line 12, in <module>
from rrd import app
File "/xxxx/rrd/__init__.py", line 4, in <module>
from flask import Flask, request, Blueprint
File "/xxxxx/2env/lib/python2.7/site-packages/flask/__init__.py", line 19, in <module>
from jinja2 import Markup, escape
File "/xxxxx/2env/lib/python2.7/site-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/xxxxx/2env/lib/python2.7/site-packages/jinja2/environment.py", line 13, in <module>
from jinja2 import nodes
File "/xxxxxx/2env/lib/python2.7/site-packages/jinja2/nodes.py", line 18, in <module>
from jinja2.utils import Markup
File "/xxxxx/2env/lib/python2.7/site-packages/jinja2/utils.py", line 520, in <module>
from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe
解决办法:
在目录/xxxx/2env/lib/python2.7/site-packages 下确实没有发现markupsafe,需要重新安装,见下面的解决办法
单独重新安装:pip install --no-index --find-links=lianxi -r ./ceshi2.txt --target=2env/lib/python2.7/site-packages
但是执行会出错,见问题2

问题2:
(2env) [root@xxxxx]$ pip install --no-index --find-links=lianxi -r ./ceshi2.txt --target=2env/lib/python2.7/site-packages
Ignoring indexes: https://pypi.python.org/simple
Collecting MarkupSafe==1.1.1 (from -r ./ceshi2.txt (line 1))
Installing collected packages: MarkupSafe
Successfully installed MarkupSafe-1.1.1
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 366, in run
for item in os.listdir(lib_dir):
OSError: [Errno 2] No such file or directory: ‘/tmp/tmp0lEZD9/lib/python‘

解决办法:增加一行lib_dir = lib_dir.replace("lib","lib64")在/usr/lib/python2.7/site-packages/pip/commands/install.py中,增加的位置如下:
if options.target_dir:
ensure_dir(options.target_dir)

lib_dir = distutils_scheme(‘‘, home=temp_target_dir)[‘purelib‘]
lib_dir = lib_dir.replace("lib","lib64")       <---------------增加到此处
for item in os.listdir(lib_dir):
target_item_dir = os.path.join(options.target_dir, item)
if os.path.exists(target_item_dir):
if not options.upgrade:

 

virtualenv中执行python脚本报错ImportError: No module named markupsafe 或 No such file or directory: '/tmp/tmp0lEZD9/lib/python'

标签:nbsp   template   env   cep   nod   targe   des   list   使用   

原文地址:https://www.cnblogs.com/qinshizhishi/p/13220942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!