我有一套现成的包裹,但有一个旧版本的詹戈。
我想做的是duplicate<>/strong>这一环境,因此,我有另一个环境,其组合恰好相同:<>but/em>,新版本的Django。 我如何能够这样做?
我有一套现成的包裹,但有一个旧版本的詹戈。
我想做的是duplicate<>/strong>这一环境,因此,我有另一个环境,其组合恰好相同:<>but/em>,新版本的Django。 我如何能够这样做?
最容易的方式是利用管道生成要求书。 要求档案基本上包含一份清单,列出你希望安装的所有假装(或已经安装在纸浆生成的档案中),以及它们重新使用的版本。
a. 编制要求文件,进入你原来的虚拟机构,运行:
pip freeze > requirements.txt
这将为你生成
Django==1.3
Fabric==1.0.1
etc...
现在,用以下文字表示:<代码>Django=x.x,表示Django==1.3<>/code>(或您希望安装的新虚拟版本)。
Lastly, activate your new virtualenv, and run:
pip install -r requirements.txt
And pip will automatically download and install all the python modules listed in your requirements.txt file, at whatever versions you specified!
Another option is to use virtualenv-clone
package:
A script for cloning a non-relocatable virtualenv.
cpvirtualenv ENVNAME [TARGETENVNAME]
方便选择使用virtualenv-clone
。 一揽子计划。
复制<代码>venv1至venv2
:
Install virtualenv-clone
, 或venv1
或圆形虚拟环境venv_dummy
。 创建<代码>venv_dummy:
python -m virtualenv venv_dummy
source venv_dummy/bin/activate
To install virtualenv-clone
:
(venv_dummy): pip install virtualenv-clone
复制venv1
至venv2
:
(venv_dummy): virtualenv-clone venv1/ venv2/
If you are using Anaconda you can just run:
conda create --name myclone --clone myenv
This will copy myenv
to the newly created environment called myclone
.
这里,我去指挥克隆的假环境。
packs=`source-path/bin/pip freeze` && python3 -m venv <env-name> && target-path/bin/pip install $packs
Conventions used in above command:
/home/john/envs/oldenv
.myenv
, it can be a path as well e.g.
/home/john/envs/myenv
/home/john/envs/<env-name>
采用这一方法的优点,或为何更愿意这样做
在某些情况下,你可能希望将全球包裹从克隆技术中删除,而你可以取代<条码>源-path/bin/pipzen>/code>,代之以<条码>>-当地条码>here。
In case you use pip "venv". I copy pasted the folder holding the virtual environment and manually changed the files in the bin folder of the copied folder. I don t know if its efficient,but it works!
Can you not simply:
pip works, but it s a problem on a computer without internet.
I wrote a small code for this, it worked for me. I m writing it here because maybe it will be useful for someone else.
(注:我用Windows 测试)
import os
# The new address of our script folder
script_folder = r D:Python proqramspdf_to_excelvenvScripts
# the old address of our venv folder
old_path = rb C:UsersAVG-dellDesktoppdf_to_excelvenv
# the new address of our venv folder
new_path = rb"D:Python proqramspdf_to_excelvenv"
def find_replace( folder ):
names = os.listdir( folder )
for name in names:
current_path = os.path.join( folder, name )
if os.path.isdir( current_path ):
find_replace( current_path )
elif os.path.isfile( current_path ) :
try:
with open( current_path , rb ) as f:
data = f.read()
if old_path in data:
print( current_path )
data2 = data.replace( old_path , new_path )
with open( current_path , wb ) as f:
f.write(data2)
except:
pass
find_replace( script_folder )
print( completed )
Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...
I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...
Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...
Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...
I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...
Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...
Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...
I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...