Piyush Jain
Piyush Jain

Reputation: 23

ModuleNotFoundError: No module named 'string' while importing flask

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.

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)] on win32 Type "help", "copyright", "credits" or "license" for more information. from flask import Flask

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'

Upvotes: 0

Views: 3716

Answers (2)

you need to remove env folder and files because has configurations of your another computer, so create a new one env and just execute pip freeze -r requeriments.txt to install depenedencies

Upvotes: 0

Druta Ruslan
Druta Ruslan

Reputation: 7412

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

some docs

Upvotes: 2

Related Questions