I created a folder via virtualenv command, but the result isn't what I wanted.
[root@localhost opt]# virtualenv my_env
New python executable in /opt/my_env/bin/**python2.6**
Also creating executable in /opt/my_env/bin/python
Installing setuptools, pip, wheel...done.
My system is CentOS 6.5. Before I created my folder I upgraded my python 2.6 to python 3.6. Then I wanted to create an isolated environment to practice Django. Unfortunately, the folder has python 2.6, it should be python 3.6. Can someone tell me what happened?
I upgraded my python 2.6 to python 3.6
In the Python universe, Python 2 and Python 3 are two different things. So what you actually did was to install Python 3 alongside Python 2. Now your system has both Python 2 (which can be run by the command python) and also Python 3 (which can be run by the command python3)
So when you ran virtualenv my_env it fired the default Python interpreter which is Python 2 in CentOS 6.x. That's the reason for Python 2.6 in your virtual environment.
Setting up Virtual Environment with Python 3
To get a Python 3 interpreter in your virtual environment run:
virtualenv -p python3 my_env
You could go with python3 -m venv env
No need for virtualenv
What you did
virtualenv my_env
is invoking the python2 virtualenv command to prepare a python2 environment.
Besides, you should have a look at Pipenv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With