Почему не создается виртуальное окружение python
Перейти к содержимому

Почему не создается виртуальное окружение python

  • автор:

Python venv не создает виртуальную среду

Однако команда не создает никаких каталогов с папками bin / include / lib. Что именно мне здесь не хватает?

enter image description here

6 ответов

У меня была такая же проблема. Я смог заставить работать venv, удалив Python и переустановив его (я использую дистрибутив Anaconda). Команда py -m venv test по-прежнему не имеет выходных данных после запуска, но теперь она создает папку для меня, и я могу активировать тестовую среду.

Почему вы должны писать python3 -m venv env , когда ваша база установлена как python3.6?

Просто сделайте pip install virtualenv , это должно установить пакет virtualenv, если он еще не установлен, тогда

virtualenv envname это запустится и должно дать вам следующее сообщение: я создал env с именем testenv :

Если вы получите это, это будет успех, иначе сообщите нам, что вы получаете, после этого вы должны cd в папку Scripts и затем запустить activate

Иногда среда пути системы не знает о virtualenv.exe

Решение:
установить virtualenv

Запустите команду в каталоге, где вы хотите виртуальную среду:

Установите и создайте через:

Затем активируйте среду, перейдя в папку ./ your_virtualenv_name / Scripts и запустите:

Pip install virtualenvwrapper-win попробуйте установить и повторить

Для тех, кто сталкивается с этой проблемой сейчас, просто измените команду на запуск python вместо python3

Python venv not creating virtual environment

however the command doesn’t create any directory with bin/include/lib folders. What exactly am I missing here?

enter image description here

Shury's user avatar

10 Answers 10

Sometime system’s path environment is not aware of virtualenv.exe

solution:
install virtualenv

run command in the directory where you want virtual environment :

Naveen Jain's user avatar

For anyone facing this issue now, simply changing the command to start python instead of python3 fixes this

Tim Crammond's user avatar

I have a Windows 10 machine and had a same problem. It was because I had multiple versions of python. Unknowingly windows had created a python.exe in the WindowsApps folder —

enter image description here

Then the solution is sometimes:(there is a huge chance that, the old %PATH% got renamed)

This python.exe had a size of 0 kb, so I deleted the python.exe in the WindowsApps folder, opened a new Command prompt and it started working.

hru_d's user avatar

why do you have to write python3 -m venv env when you base is installed as python3.6 itself?

Just do pip install virtualenv this should install virtualenv package if not already installed, then

virtualenv envname this will run and should give you a message like this, I have created a env called testenv :

If you get this, it is a success, else do let us know what you get, after this you must cd into the Scripts folder and then run activate

I was having this same problem. I was able to get venv working by uninstalling Python and reinstalling it (I’m using the Anaconda distribution). The py -m venv test command still doesn’t have any output after running it, but now it creates a folder for me and I can activate the test environment.

Ru Chern Chong's user avatar

Try this (works for me)

Install and create through:

Then activate the environment, by going to ./your_virtualenv_name/Scripts folder and then run:

7wick's user avatar

I guess I am a bit late to answer the question, but before creating a virtual environment always check if we already have a .venv hidden folder

  1. Navigate to the directory where we want to create a virtual environment
  2. Check if we already have one by ls -la this command will show us the hidden folders, as .venv will be hidden by default Check hidden folder using Terminal/Command prompt
  3. If we do not have the .venv folder (name is up to us), then create one by mkdir .venv to follow the best convention, in this folder we can create multiple virtual environments
  4. Now we can create a virtual environment by python3 -m venv ./venv/drf
  5. In above folder we have created, inside that we are creating one more folder drf (Django Rest Rramework) enter image description here
  6. At last to run our virtual environment use source .venv/drf/bin/activate by this command we are running the script which is there in bin folder enter image description here

I hope I was able to explain, as I am also learning

Please feel free to edit or make any changes in the post, If something is wrong

Error creating virtualenv with python3.6 #1059

Earlier today I installed python3.6 on my debian machine. Python3.6 was made available in buster distribution. When I try to create a virtualenv with python3.6.

gives the following error.

The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.

You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.

Failing command: [‘/home/float/test/t/bin/python3.6’, ‘-Im’, ‘ensurepip’, ‘—upgrade’, ‘—default-pip’]

I do have python3-venv (3.5.3-1) installed. Why do I get this error? If I run the command

I don’t have trouble creating virtualenvs using the default python3 version (3.5.3).

Also , I noticed that I can create a virtualenv as follows:

The text was updated successfully, but these errors were encountered:

Reinstalling didn’t work. I will close this issue now. I will update if I have any more information.

@animeshb , you don’t have more output after

Failing command: [‘/home/float/test/t/bin/python3.6’, ‘-Im’, ‘ensurepip’, ‘—upgrade’, ‘—default-pip’]

Nothing after that line.

In the venv/bin folder, it doesn’t have activate command.

I can only redirect you to one of many pages matching this error (it’s a known prob with debian/ubuntu systems):

what about sudo apt-get install python3-pip ?

The original poster’s problem is due to not having the ‘python3.6-venv’ package installed, which can be verified using Docker if you don’t have access to a buster Debian:

Install ‘python3.6-venv’, and it should work.

Wow, it didn’t occur to me at all that there would be a version specific -venv package. Installing this did the trick.

@gst and @eukaryote Thank you so much for spending your time on this issue.

The solution by @eukaryote worked for me. Thanks for posting this!

Wrongly configured locale can also induce this problem, as this answer solves my problem that produces the same error message as OP.

only one datapoint, but messing about with a fresh virtualbox ubuntu bionic, i found that apt install python3.6-venv still left me with a broken python3.6 -m venv , but running apt install python3-venv fixed it.

I’m on Debian testing/buster and I’m having this same issue, while both python3.6-venv and python3-venv are both installed.

nikolas
They write there that it is repaired in the last version. So I made
apt purge python3.6-venv
dpkg -i —force-depends-version python3.6-venv_3.6.6

rc1-3_amd64.deb # from snapshot.debian.org
and it works for me.
Probably I will need fix later: apt —fix-broken install

Just leaving a comment here, for the ones who arrive after me, googling for the same problem:

the same applies to 3.7 of python, you have to install python3.7-venv , that is apt-get install python3.7-venv

Just FYI, the above solution does not in fact work for python 3.7. apt install python3.7 python3.7-venv on a stock buster docker image still produces a broken virtualenv («ensurepip is not available»). However, after apt install python3-venv (which needlessly installs all of python3.6), you can create a working python 3.7 venv including a proper 3.7 pip, with python3.7 -m venv myvenv . So the complete working command set is this:

(btw, note that all python3.7-venv installs is a dummy system ensurepip module.)

you’re talking about venv , which is a different project. This tracker is for virtualenv.

I was also facing the same issue.

]$/python/v3.7.0/bin/python3 -m venv avd
Error: Command ‘[‘/home/niraj/avd/bin/python3’, ‘-Im’, ‘ensurepip’, ‘—upgrade’, ‘—default-pip’]’ returned non-zero exit status 1.

After adding libffi3.3 on my LD_LIBRARY path it works

setenv LD_LIBRARY_PATH /libffi/v3.3/lib64

Fisrt I’ve installed with sudo apt install python3-venv and had the same problem and, it was solved by doing: sudo apt install python3.6-venv

Не удается установить через pip с Virtualenv

Ниже приведена ошибка, которую я получаю при запуске pip :

7 ответов

Создайте свою виртуальную среду в пути без пробелов. Вот почему это происходит:

Когда вы создаете среду, она устанавливает каталог bin . В этом каталоге bin все исполняемые файлы, относящиеся к среде. Некоторые из них — скрипты. Как вы, возможно, знаете, hashbangs используются, чтобы сообщить системе, какой интерпретатор использовать для запуска script. Вы можете часто видеть это в верхней части скриптов:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *