How to use python virtual environment in another computer

后端 未结 3 1975
感动是毒
感动是毒 2020-12-28 09:35

I have created an virtual environment by using virtualenv pyenv in my linux system. Now i want to use the virtual environment in another computer. Can i direct

3条回答
  •  甜味超标
    2020-12-28 09:59

    You should not. The other computer can have a different operating system, other packages or package versions installed, so copying the files will not work.

    The point of a virtual environment is to be able to replicate it everywhere you need it.

    Make a script which installs all necessary dependencies from a requirements.txt file and use it.

    Use pip freeze > requirements.txt to get the list of all python packages installed. Then install the dependencies in another virtual environment on another computer using pip install -r requirements.txt.

    If you want the exact environment, including system packages, on another computer, use Docker.

提交回复
热议问题