ModuleNotFoundError:导入烧瓶时,没有名为"string"的模块 [英] ModuleNotFoundError: No module named 'string' while importing flask

查看:57
本文介绍了ModuleNotFoundError:导入烧瓶时,没有名为"string"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的PC上有我的项目.我正在尝试在其他PC上传输它.我在虚拟环境中安装了每个软件包,例如flask,flask-security等,它在我的PC上运行良好.

I have my project working on my pc. I am trying to transfer it on different PC. I have every package installed in virtualenvironment like flask, flask-security etc and it works great on my pc.

但是,当我将其传输到另一台PC时,它会失败.它甚至无法导入Flask并失败.

But when I transfer it to other pc it fails. It cannot even import the Flask and fails with .

(env) E:\quickAuto>env\Scripts\python.exe
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bi

t(AMD64)]在Win32上键入帮助",版权",信用"或许可证"以获取更多信息.从烧瓶进口烧瓶

t (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. from flask import Flask

回溯(最近通话最近):文件",第1行,在在第17行中的文件"E:\ quickAuto \ env \ lib \ site-packages \ flask__init __.py"从werkzeug.exceptions导入中止文件"E:\ quickAuto \ env \ lib \ site-packages \ werkzeug__init __.py",第151行,在导入("werkzeug.exceptions")文件"E:\ quickAuto \ env \ lib \ site-packages \ werkzeug \ exceptions.py",第67行,
在从werkzeug._internal导入_get_environ文件"E:\ quickAuto \ env \ lib \ site-packages \ werkzeug_internal.py",第12行在导入字符串ModuleNotFoundError:没有名为字符串"的模块

Traceback (most recent call last): File "", line 1, in File "E:\quickAuto\env\lib\site-packages\flask__init__.py", line 17, in from werkzeug.exceptions import abort File "E:\quickAuto\env\lib\site-packages\werkzeug__init__.py", line 151, in import('werkzeug.exceptions') File "E:\quickAuto\env\lib\site-packages\werkzeug\exceptions.py", line 67,
in from werkzeug._internal import _get_environ File "E:\quickAuto\env\lib\site-packages\werkzeug_internal.py", line 12, in import string ModuleNotFoundError: No module named 'string'

推荐答案

如果使用 virtualenv 文件夹复制所有项目,这是一个不好的做法,则只需复制具有> requirements.txt 文件,然后从 requirements.txt 安装所有软件包,例如:

If you copy all project with the virtualenv folder this is a bad practice, you need only to copy the project with the requirements.txt file, and install all packages from requirements.txt for example:

# activate your virtualenv on your PC
. env/bin/activate

# now we need to create a requirements.txt file with `pip freeze`
pip freeze > requirements.txt

# now in our folder we have a `requirements.txt` file with all our packages

# after this copy all your packge without `virtualenv` folder,
# but with `requirements.txt file


# when you are on another PC create a new `virtualenv` activate it and install 
# the packages from `requirements.txt` with this command

pip install -r requirements.txt

一些文档

这篇关于ModuleNotFoundError:导入烧瓶时,没有名为"string"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆