简体   繁体   中英

How to install virtualenv for python3?

I am creating a Django App and stuck at virtualenv installation. I have seen this and tried to follow but it resulted in this everytime I tried something. Why can't it take python 3 for installing but this works virtualenv venv but it installs for python 2. What should I do?

virtualenv -p python3 venv
Running virtualenv with interpreter /home/oroborus/anaconda3/bin/python3
Using base prefix '/home/oroborus/anaconda3'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
venv/bin/python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable venv/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/home/oroborus/PycharmProjects/test-app' (should be '/home/oroborus/PycharmProjects/test-app/venv')
ERROR: virtualenv is not compatible with this system or executable

Typing locate libpython3.5

locate libpython3.5
/home/oroborus/anaconda3/envs/tensorflow/lib/libpython3.5m.so
/home/oroborus/anaconda3/envs/tensorflow/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/envs/tensorflow/lib/python3.5/config-3.5m/libpython3.5m.a
/home/oroborus/anaconda3/lib/libpython3.5m.so
/home/oroborus/anaconda3/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/lib/python3.5/config-3.5m/libpython3.5m.a
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/libpython3.5m.so
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/python3.5/config-3.5m/libpython3.5m.a

In debian like distros python3-venv is available.

Install it using apt sudo apt-get install python3 python3-venv .

Then use it like that python3 -m venv yourvenvfoldername .

EDIT :

In this case anaconda is used, which has the replacement conda for both, pip and virtualenv. There is nice command comparison table available in the docs .

Creating a virtualenv with conda can be done like that:

conda create --name $ENVIRONMENT_NAME python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM