-1

I have created a virtualenv (called monoi_django_virtualenv) on my old PC, which worked fine. I have copied and pasted my virtualenv folder onto my new PC, but it does not work. Why ?

When I activate it and run pip list command, all my packages / modules are not displaying ...

(monoi_django_virtualenv) C:\Users\myname\Documents\monoi_django_virtualenv>pip list
Package    Version
---------- -------
pip        21.1.1
setuptools 56.0.0
WARNING: You are using pip version 21.1.1; however, version 21.2.4 is available.
You should consider upgrading via the 'c:\python39\python.exe -m pip install --upgrade pip' command.

Files and folders in Scripts

(monoi_django_virtualenv) C:\Users\myname\Documents\monoi_django_virtualenv\Scripts>dir
 Le volume dans le lecteur C n’a pas de nom.
 Le numéro de série du volume est 9AEC-46F0

 Répertoire de C:\Users\myname\Documents\monoi_django_virtualenv\Scripts

20/08/2021  14:59    <DIR>          .
20/08/2021  14:59    <DIR>          ..
17/04/2021  19:52             2 417 activate
17/04/2021  19:52             1 060 activate.bat
17/04/2021  19:52             3 110 activate.fish
17/04/2021  19:52             1 755 activate.ps1
17/04/2021  19:52             1 201 activate.xsh
17/04/2021  19:52             1 193 activate_this.py
18/04/2021  12:11           106 397 chardetect.exe
17/04/2021  19:52               510 deactivate.bat
17/04/2021  22:42           106 439 django-admin.exe
17/04/2021  22:42               724 django-admin.py
15/08/2021  20:59           106 392 f2py.exe
11/08/2021  21:14           106 426 faker.exe
11/08/2021  21:13           106 397 pip.exe
11/08/2021  21:13           106 397 pip3.9.exe
11/08/2021  21:13           106 397 pip3.exe
11/08/2021  21:15           106 397 py.test.exe
17/04/2021  19:52                24 pydoc.bat
18/04/2021  12:23           106 385 pyjson5.exe
11/08/2021  21:15           106 397 pytest.exe
17/04/2021  19:52           539 312 python.exe
17/04/2021  19:52           537 776 pythonw.exe
17/04/2021  22:42           106 392 sqlformat.exe
17/04/2021  19:52           106 384 wheel-3.9.exe
17/04/2021  19:52           106 384 wheel.exe
17/04/2021  19:52           106 384 wheel3.9.exe
17/04/2021  19:52           106 384 wheel3.exe
20/08/2021  14:59    <DIR>          __pycache__
              26 fichier(s)        2 685 034 octets
               3 Rép(s)   4 387 307 520 octets libres

Files and folders in site-packages

(monoi_django_virtualenv) C:\Users\myname\Documents\monoi_django_virtualenv\Lib\site-packages>dir
 Le volume dans le lecteur C n’a pas de nom.
 Le numéro de série du volume est 9AEC-46F0

 Répertoire de C:\Users\myname\Documents\monoi_django_virtualenv\Lib\site-packages

20/08/2021  14:59    <DIR>          .
20/08/2021  14:59    <DIR>          ..
20/08/2021  14:57    <DIR>          asgiref
20/08/2021  14:57    <DIR>          asgiref-3.3.4.dist-info
20/08/2021  14:57    <DIR>          atomicwrites
20/08/2021  14:57    <DIR>          atomicwrites-1.4.0.dist-info
20/08/2021  14:57    <DIR>          attr
20/08/2021  14:57    <DIR>          attrs-21.2.0.dist-info
20/08/2021  14:57    <DIR>          certifi
20/08/2021  14:57    <DIR>          certifi-2020.12.5.dist-info
20/08/2021  14:57    <DIR>          cffi
20/08/2021  14:57    <DIR>          cffi-1.14.5.dist-info
20/08/2021  14:57    <DIR>          chardet
20/08/2021  14:57    <DIR>          chardet-4.0.0.dist-info
20/08/2021  14:57    <DIR>          colorama
20/08/2021  14:58    <DIR>          colorama-0.4.4.dist-info
20/08/2021  14:58    <DIR>          cryptography
20/08/2021  14:58    <DIR>          cryptography-3.4.7.dist-info
20/08/2021  14:58    <DIR>          DateTime
20/08/2021  14:58    <DIR>          DateTime-4.3.dist-info
20/08/2021  14:58    <DIR>          dateutil
17/04/2021  19:52               152 distutils-precedence.pth
20/08/2021  14:58    <DIR>          django
20/08/2021  14:58    <DIR>          Django-3.2.dist-info
20/08/2021  14:58    <DIR>          django_extensions
20/08/2021  14:58    <DIR>          django_extensions-3.1.3.dist-info
20/08/2021  14:58    <DIR>          django_paypal-1.1.1.dist-info
11/08/2021  21:17            14 953 dot_parser.py
20/08/2021  14:58    <DIR>          et_xmlfile
20/08/2021  14:58    <DIR>          et_xmlfile-1.1.0.dist-info
20/08/2021  14:58    <DIR>          factory
20/08/2021  14:58    <DIR>          factory_boy-3.2.0.dist-info
20/08/2021  14:58    <DIR>          faker
20/08/2021  14:58    <DIR>          Faker-8.11.0.dist-info
20/08/2021  14:58    <DIR>          idna
20/08/2021  14:58    <DIR>          idna-2.10.dist-info
20/08/2021  14:58    <DIR>          inflection
20/08/2021  14:58    <DIR>          inflection-0.5.1.dist-info
11/08/2021  21:16            11 437 inflection.py
20/08/2021  14:58    <DIR>          iniconfig
20/08/2021  14:58    <DIR>          iniconfig-1.1.1.dist-info
20/08/2021  14:58    <DIR>          jinja2
20/08/2021  14:58    <DIR>          Jinja2-2.11.3.dist-info
20/08/2021  14:58    <DIR>          json5
20/08/2021  14:58    <DIR>          json5-0.9.5.dist-info
20/08/2021  14:58    <DIR>          markupsafe
20/08/2021  14:58    <DIR>          MarkupSafe-1.1.1.dist-info
20/08/2021  14:59    <DIR>          numpy
20/08/2021  14:59    <DIR>          numpy-1.21.1.dist-info
20/08/2021  14:59    <DIR>          openpyxl
20/08/2021  14:59    <DIR>          openpyxl-3.0.7.dist-info
20/08/2021  14:59    <DIR>          OpenSSL
20/08/2021  14:59    <DIR>          packaging
20/08/2021  14:59    <DIR>          packaging-21.0.dist-info
20/08/2021  14:59    <DIR>          pandas
20/08/2021  14:59    <DIR>          pandas-1.3.2.dist-info
20/08/2021  14:59    <DIR>          pathlib2
20/08/2021  14:59    <DIR>          pathlib2-2.3.5.dist-info
20/08/2021  14:59    <DIR>          paypal
20/08/2021  14:59    <DIR>          pdfkit
20/08/2021  14:59    <DIR>          pdfkit-0.6.1.dist-info
20/08/2021  14:59    <DIR>          PIL
20/08/2021  14:59    <DIR>          Pillow-8.2.0.dist-info
20/08/2021  14:59    <DIR>          pip
20/08/2021  14:59    <DIR>          pip-21.2.3.dist-info
20/08/2021  14:59    <DIR>          pkg_resources
20/08/2021  14:59    <DIR>          pluggy
20/08/2021  14:59    <DIR>          pluggy-0.13.1.dist-info
20/08/2021  14:59    <DIR>          py
20/08/2021  14:59    <DIR>          py-1.10.0.dist-info
20/08/2021  14:59    <DIR>          pycparser
20/08/2021  14:59    <DIR>          pycparser-2.20.dist-info
20/08/2021  14:59    <DIR>          pydot-1.4.2.dist-info
11/08/2021  21:17            54 932 pydot.py
20/08/2021  14:59    <DIR>          pyOpenSSL-20.0.1.dist-info
20/08/2021  14:59    <DIR>          pyparsing-2.4.7.dist-info
11/08/2021  21:15           273 365 pyparsing.py
20/08/2021  14:59    <DIR>          pytest
20/08/2021  14:59    <DIR>          pytest-6.2.4.dist-info
20/08/2021  14:59    <DIR>          pytest_django
20/08/2021  14:59    <DIR>          pytest_django-4.4.0.dist-info
20/08/2021  14:59    <DIR>          pytest_factoryboy
20/08/2021  14:59    <DIR>          pytest_factoryboy-2.1.0.dist-info
20/08/2021  14:59    <DIR>          python_dateutil-2.8.2.dist-info
20/08/2021  14:59    <DIR>          pytz
20/08/2021  14:59    <DIR>          pytz-2021.1.dist-info
20/08/2021  14:59    <DIR>          requests
20/08/2021  14:59    <DIR>          requests-2.25.1.dist-info
20/08/2021  14:59    <DIR>          selenium
20/08/2021  14:59    <DIR>          selenium-3.141.0.dist-info
20/08/2021  14:59    <DIR>          setuptools
20/08/2021  14:59    <DIR>          setuptools-54.1.2.dist-info
17/04/2021  19:52                 0 setuptools-54.1.2.virtualenv
20/08/2021  14:59    <DIR>          six-1.15.0.dist-info
18/04/2021  12:11            34 159 six.py
20/08/2021  14:59    <DIR>          sqlparse
20/08/2021  14:59    <DIR>          sqlparse-0.4.1.dist-info
20/08/2021  14:59    <DIR>          stripe
20/08/2021  14:59    <DIR>          stripe-2.60.0.dist-info
20/08/2021  14:59    <DIR>          text_unidecode
20/08/2021  14:59    <DIR>          text_unidecode-1.3.dist-info
20/08/2021  14:59    <DIR>          toml
20/08/2021  14:59    <DIR>          toml-0.10.2.dist-info
20/08/2021  14:59    <DIR>          urllib3
20/08/2021  14:59    <DIR>          urllib3-1.26.4.dist-info
20/08/2021  14:59    <DIR>          wheel
20/08/2021  14:59    <DIR>          wheel-0.36.2.dist-info
17/04/2021  19:52                 0 wheel-0.36.2.virtualenv
20/08/2021  14:59    <DIR>          zope
18/04/2021  13:29               530 zope.interface-5.4.0-py3.9-nspkg.pth
20/08/2021  14:59    <DIR>          zope.interface-5.4.0.dist-info
18/04/2021  12:39           182 784 _cffi_backend.cp39-win_amd64.pyd
20/08/2021  14:59    <DIR>          _distutils_hack
20/08/2021  14:59    <DIR>          _pytest
17/04/2021  19:52                18 _virtualenv.pth
17/04/2021  19:52             5 792 _virtualenv.py
20/08/2021  14:59    <DIR>          __pycache__
              12 fichier(s)          578 122 octets
             105 Rép(s)   4 397 076 480 octets libres

Is this problem related to the python path ?

sys.path

C:\Python39>python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', 'C:\\Python39\\python39.zip', 'C:\\Python39\\DLLs', 'C:\\Python39\\lib', 'C:\\Python39', 'C:\\Python39\\lib\\site-packages']

AlexisLP
  • 53
  • 1
  • 13

1 Answers1

0

Coping virtual environment just by using copy/paste is not really good idea for many reasons: you can have different python versions, OS, hardware and low-level libraries. So there is a lot of reasons why it can be broken.

Better idea is reinstall venv with all the same packages and package versions. Link in comment answers it perfectly: https://stackoverflow.com/a/7438771/4960953 In two words you need to create list of all your packages first:

pip freeze > requirements.txt

Create new empty venv on your new PC:

python3 -m venv /path/to/new/virtual/environment

See more here: https://docs.python.org/3/library/venv.html Copy your requirements.txt on new PC. And then install all the same packages from this file:

pip install -r requirements.txt
Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102