Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to copy a virtual env to another compute and make it works? #1035

Closed
gwenxia opened this issue Apr 11, 2017 · 4 comments
Closed

How to copy a virtual env to another compute and make it works? #1035

gwenxia opened this issue Apr 11, 2017 · 4 comments

Comments

@gwenxia
Copy link

gwenxia commented Apr 11, 2017

1, I create a virtual env in linux server A,,which has installed python2.7,blow as detailed steps:
virtualenv ./python27env
source ./python27env/bin/activate
pip install xxxxx1
pip instal xxxxx2
virtualenv --relocatable ./
deactivate
2, now make virtualenv python27env as a tar file:
tar -cvf python27env.tar.gz ./python27env
3.use scp command copy above python27env.tar.gz to linux server B, which only has installed python2.6, blow as detailed steps:
tar -xvf python27env.tar.gz
virtuaenv ./python27env ----no-site-packages
source ./python27env/bin/activate
4.question
A,now run cmd "ls ./python27env/lib", the result present both python2.6 and python2.7, how to only remain python2.7?
B.run cmd "which python" returns python path in virtualenv,but when I run cmd "python -V" it returns Python2.6.6? actually the python2.7 is myi expect.

notes:My actual work scene is: my application is developed under python2.7 and it dependencies many 3rd packages, I want deploy my application to the servers which are installed python2.6 or other versions(python3.x), and other servers can not use pip to install packages due to these servers can not connect internet. I am not sure virtualenv is fit for me?
Thanks for your reply!

@pfmoore
Copy link
Member

pfmoore commented Apr 11, 2017

Sorry, but that's not a supported situation. Your most practical solution would likely be to manually download the packages you need, and put them in a location that is accessible to the Python 2.6 servers, and then install them with pip using --find-links to direct pip to install from your local copies.

An alternative might be to put Python 2,6 on your development system, build a virtualenv as you describe but using Python 2.6, and then copy that virtualenv to the target servers. But frankly, that's still a high-risk approach and I don't believe we'd support that, so if you did hit issues you'd have to resolve them on your own. The --relocatable flag was never (as far as I am aware) intended for copying environments between machines.

@gwenxia
Copy link
Author

gwenxia commented Apr 12, 2017

Thanks for your reply.First I want to reslove below two questions,do you have any suggestion?
1,when I run cmd "ls ./python27env/lib", the result present both python2.6 and python2.7, it means current system's python version has embedded to virtualenv too. how to only remain python2.7?

2.when I run cmd "which python" returns python path in virtualenv,but run cmd "python -V" it returns Python2.6.6? actually the python2.7 is my expect. how to set python2.7 of virtualenv supported as system default python version?

Appreciate your reply!

@pfmoore
Copy link
Member

pfmoore commented Apr 12, 2017

Honestly, I've no idea how to answer your questions. You simply shouldn't do that and if you do things will fail in unexpected ways. You have copied a partial but incomplete Python 2.7 installation to the target machine which doesn't have Python 2.7 on, but does have Python 2.6 (presumably in the system directory where Python 2.7 would expect the system install of Python 2.7 to be present). It's hard to see how anything sensible could happen in a situation like that.

@gaborbernat
Copy link
Contributor

This is out of scope for this project.

@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants