0

When I create the virtualenv, if I do not add the --no-site-packages as param:

virtualenv venv 

I can get the packages, in the

venv/lib/

there are a python2.7 package:

python2.7 

under the python2.7 there are site-packages.

But, I have a requirement, I want copy the python3.5 to the venv/lib/ how can I do this?


EDIT-1

I use the post method create the venv, in the venv/lib/:

there is the python3.5 directory, but in the venv/lib/python3.5/site-packages there are few packages:

enter image description here

But in my Mac's sitepages:

there are so many packages, my requirement is add those packages in the venv when create the venv:

my origin site-packages path is:/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages

enter image description here


EIDT-2

Before, I do not use virtualenv, I have installed many site-packages in my Mac, (/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages), and I want to use venv now, so I am looking for a method to create the venv and the site-packages I have installed should include in it.

sof-03
  • 2,255
  • 4
  • 15
  • 33
  • 1
    Possible duplicate of [Using Python 3 in virtualenv](https://stackoverflow.com/questions/23842713/using-python-3-in-virtualenv) – w411 3 May 08 '18 at 11:43
  • @waLLe Hi, friend, see my post, my requirement is add the site-packages to the new created `venv`, but I use the accepted and high upvoted answer, there do not get the effect. – sof-03 May 08 '18 at 12:12

1 Answers1

0

First of all you should install virtualenv using python3.5.
there is a tricky way that I use, I add some lines to the .bashrc file like this:

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
alias v.activate="source /usr/local/bin/virtualenvwrapper.sh"

so whenever I want to change my virtualenv to be on python3.5 I run the v.activate command, and then create my virtual environment with python3.5.

remember this that:

1.I use virtualenvwrapper instead of virtualenv

2.Dont forget to run source .bashrc after you add those lines to bashrc

Community
  • 1
  • 1
Mehrdad Pedramfar
  • 10,941
  • 4
  • 38
  • 59
  • Do you know my requirement? I want when create the `venv` I add the packages of `/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages` to it. – sof-03 May 08 '18 at 12:59
  • You want to transfer the packages from python2.7 to 3.5 ? – Mehrdad Pedramfar May 08 '18 at 13:00
  • No, before I do not use virtualenv, I have installed many site-packages in my Mac, (`/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages`), and I want to use `venv` now, so I am looking for a method to create the `venv` and the site-packages I have installed should include in it. – sof-03 May 09 '18 at 02:42
  • so install them again after you activate the virtual environment. whats the problem ? the versions ? – Mehrdad Pedramfar May 09 '18 at 04:26
  • I mean, whether there is a way I do not need install in the virtual enviroment. – sof-03 May 09 '18 at 05:15