venv doesn't create activate script python3

前端 未结 5 730
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 00:02

When trying to create a virtulenv using venv with python 3 on ubuntu it isn’t creating an activate script. It conitunally exits with an error 1.

Following docs and o

相关标签:
5条回答
  • 2020-12-23 00:26

    The command:

    python3 -m virtualenv env
    

    works for me, whereas:

    python3 -m venv env
    

    does not.

    0 讨论(0)
  • 2020-12-23 00:26
    sudo python3 -m venv venv/
    

    if in doubt, always try as a superuser

    0 讨论(0)
  • 2020-12-23 00:41

    Looks like you are using Ubuntu 14.04. It was shipped with a broken pyvenv. There is a simple work around to create venv using Python 3

    1. Create venv without pip

    python3 -m venv --without-pip test4
    

    or

    pyvenv-3.4 --without-pip test4
    

    2. Get pip in your env

    source test4/bin/activate
    curl https://bootstrap.pypa.io/get-pip.py | python
    deactivate
    source test4/bin/activate
    

    or

    pyvenv-3.4 --without-pip myvenv
    source ./myvenv/bin/activate
    wget https://pypi.python.org/packages/source/s/setuptools/setuptools-3.4.4.tar.gz
    tar -vzxf setuptools-3.4.4.tar.gz
    cd setuptools-3.4.4
    python setup.py install
    cd ..
    wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz
    tar -vzxf pip-1.5.6.tar.gz
    cd pip-1.5.6
    python setup.py install
    cd ..
    deactivate
    source ./myvenv/bin/activate
    

    Source: HackerNews, AskUbuntu

    0 讨论(0)
  • 2020-12-23 00:42

    Anaconda involucred.

    If you are using Anaconda or Miniconda this solution may help:

    Conda manages python itself as a package, so that conda update python is possible, in contrast to pip, which only manages Python packages. Conda is available in Anaconda and Miniconda (an easy-to-install download with just Python and conda).

    So, this command would help:

    conda update python
    

    very disturbing for me but well, hands to the keyboard in a terminal window: (click here, see the picture)

    Thanks for your attention, have a nice day!

    0 讨论(0)
  • 2020-12-23 00:46

    This worked for me:

    python3 -m venv --without-pip test4
    

    Once I typed that in the terminal, the "test4" venv was created. And the 'activate' script was also created in the 'bin' directory.

    To anyone using python3, having trouble with this, just substitute the name of the directory you want to create for "test4" (or rename it later).

    That should do it.

    0 讨论(0)
提交回复
热议问题