0
votes

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'

2
you copy your package with virtualenv folder ?Druta Ruslan
yes all the packages are in the env\Lib\Site-packages folderPiyush Jain
I think it is somehow related to sys.path because i can see that sys.path contains references from the pc that I copied from.. Look at the c:\\users\piyujain... this path is coming from my original PC.. How can i fix this? >>> print (sys.path) ['', 'E:\\quickAuto\\env\\Scripts\\python36.zip', 'E:\\quickAuto\\env\\DLLs', 'E :\\quickAuto\\env\\lib', 'E:\\quickAuto\\env\\Scripts', 'c:\\users\\piyujain\\ap pdata\\local\\continuum\\anaconda3\\Lib', 'c:\\users\\piyujain\\appdata\\local\\ continuum\\anaconda3\\DLLs' , 'E:\\quickAuto\\env', 'E:\\quickAuto\\env\\lib\\sit e-packages'] >>>Piyush Jain

2 Answers

2
votes

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

0
votes

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