在没有Internet连接的情况下安装Virtualenv [英] Install Virtualenv without internet connectivity

查看:534
本文介绍了在没有Internet连接的情况下安装Virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建立一个实验室环境,使观众不一定能在会场建立互联网连接.我只需要向观众解释一些软件包.

I need to set up a lab environment where the audience may not necessarily have internet connectivity at the venue. There are just a few packages that I need to explain to the audience.

我正在尝试使用virtualenv来完成所有这一切.因此,使用pip install我已经能够成功安装virtualenv.在此之后,我激活了我的虚拟环境.然后在那里,我再次使用pip install来安装其他必需的模块,例如请求等.

I am trying to make use of virtualenv to do all this. So using pip install I have successfully been able to install virtualenv. After this I activate my virtual env. And then while in there I use pip install again to install the other required modules, like requests etc.

现在,由于我的听众在培训期间可能没有互联网连接,因此我希望能够将我的virtualenv分发给他们,以便他们拥有一个完整的工作环境,并且他们可以从培训的主要内容开始.

Now since my audience may not have internet connectivity during the training, I want to be able to distribute my virtualenv to them, so that they have a fully working environment and they can just get started with the main content of the training.

我不确定如何将我的virtualenv分发给其他人.据我了解,我可以做到

I am not sure how to distribute my virtualenv to others. From what I understand, I can do

点冻结> requirements.txt

pip freeze > requirements.txt

然后

pip install -r requirements.txt

pip install -r requirements.txt

但是上面的后者也需要在virtualenv内部完成才能工作.如果我错了,请纠正我.

But the latter above will also need to be done from within a virtualenv to work. Please correct me if I am wrong.

因此,我尝试编写一个Python脚本来自动完成所有这些工作,并鉴于Internet连接问题,在我的自动化脚本中,我无法使用pip install来安装virtualenv.因此,我改为使用setup.py安装virtualenv.

So I tried writing a python script that would automate all of this stuff and given the internet connectivity issue, in my automated script I can not use pip install to install virtualenv. Hence I am instead using setup.py to install virtualenv.

以下是我尝试的脚本(无效)

Below is my attempt at the script (which does not work)

import os
import shutil
import sys
from os.path import expanduser
from os.path import join

home = expanduser("~")
newpath = join(home,"newFolder")
print newpath
if not os.path.exists(newpath):
    os.makedirs(newpath)

cwd = os.path.dirname(os.path.abspath(__file__))
print cwd
#virtenv = join(cwd,'virtualenv-13.1.2')
#print virtenv
setupFile = join(cwd,'setup.py')
string = sys.executable + " " + setupFile + " install"
print string
os.system(string)
# isntalling dependencies
string = "pip install -r requirements.txt"
os.system(string)

这个想法是-当用户运行上述脚本(没有任何互联网)时,应该在其主目录下的新文件夹中设置一个virtualenv.然后,在该虚拟环境中,脚本应运行pip install -r requirements.txt以安装所有必需的模块.

The idea is - when the user runs the above script (without any internet), there should be a virtualenv set up in a new folder under his home directory. And then inside that virtual env the script should run pip install -r requirements.txt to install all the required modules.

到目前为止,以上脚本无法满足需要.并且我已将以上脚本放置在与virtualenv设置文件相同的目录中.

So far the above script does not do what's needed. And I have placed the above script in the same dir as virtualenv setup files.

我什至在想什么吗?我该如何实现?

Am I even thinking straight ? How can I achieve this ?

推荐答案

我很确定您要做的是通过在计算机上运行Web服务器来使用要分发的软件包建立自己的简单存储库. ,然后将服务器作为存储库添加到参加活动的人员-允许他们使用以下命令访问本地网络上的存储库:

I'm pretty sure that what you want to do is to establish your own simple repository with the packages you want to distribute by running a web server on your computer, and then adding your server as a repository to people attending your event - allowing them to access your repository on the local network using a command like:

pip install --extra-index-url https://IP_ADDRESS_OF_YOUR_SERVER/ yourappname

此页面很好地指导了如何进行全部设置.

This page has a pretty good guide on how to set that all up.

这篇关于在没有Internet连接的情况下安装Virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆