简体   繁体   English

将项目从一台计算机移动到另一台

[英]Moving project from one computer to another

I have a project I built in python 2.7 on one PC. 我有一个我在一台PC上用python 2.7构建的项目。 It uses djagno 1.4.5 and some other modules that are kept in site-packages. 它使用djagno 1.4.5和其他一些保存在站点包中的模块。 I tried to copy the contents of Lib\\site-packages to the new PC Python install, but I get missing module errors when I try to run manage.py runserver. 我试图将Lib \\ site-packages的内容复制到新的PC Python安装中,但是当我尝试运行manage.py runserver时,我得到了模块错误。 Do I have to install everything again on the new pc and just transfer the project files? 我是否必须在新电脑上再次安装所有内容并转移项目文件?

Usually, you keep a list of your project requirements in requirements.txt and keep the file at the root of your project. 通常,您在requirements.txt保留项目需求列表,并将文件保留在项目的根目录中。 Example requirements.txt content: 示例requirements.txt内容:

Django==1.6.5
lxml==3.3

On the new computer, you clone the repository containing the project source code (or get it different way), then install the requirements via pip python package manager: 在新计算机上,您克隆包含项目源代码的存储库(或以不同方式获取),然后通过pip python包管理器安装需求:

pip install -r requirements.txt

Also, having separate virtual environments for every project is basically must have. 此外,基本上必须为每个项目提供单独的虚拟环境


In order to create the list of requirements from your current python environment (virtual or system-wide), run: 要从当前的python环境(虚拟或系统范围)创建需求列表,请运行:

pip freeze > requirements.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM