Меню

Non zero exit code 2 pycharm ошибка

To not make project in the venv/Scripts/ directory, add path while executing django-admin startproject [project-name-that-you-want] [project-directory-path] this command.
This will let you have your django project in the directory you want, so that your project directory looks like the ones that you can find in tutorial videos.

answered May 2, 2022 at 2:12

Brad Lee's user avatar

As you can see, PyCharm has given you a «proposed solution», so use that.

Basically, PyCharm is trying to add, or you have tried to add, a --build-dir argument to the pip command but pip doesn’t know what --build-dir means.

Open your Terminal/Command Prompt, cd into your project directory and run pip install django.

answered Apr 26, 2022 at 5:17

HeyHoo's user avatar

HeyHooHeyHoo

3252 silver badges18 bronze badges

Open Pycharm settings and go to Interpreter settings File->Settings->Project->Project Interpreter and click the + button on right side, then find django and
install it.

answered Apr 26, 2022 at 5:24

Ali Aref's user avatar

Ali ArefAli Aref

1,50111 silver badges27 bronze badges

preface

When using pycharm to install a third-party package in the python virtual environment in Python interpreter settings, it is likely to report an error: non zero exit code (2), as shown in the figure:

even upgrading pip will report an error, as shown in the figure:

Tips are as follows:

Try to run this command from the system terminal. 
Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 
'D:Program FilesPythonpy36-basic-vScriptspython.exe'.

As above belongs, the official says the possible reason is that pip is not installed in the specified directory of the virtual environment, and suggests running the pip command in the terminal to install the third-party package.

The official hint has a certain degree of reasonableness, but it does not try all cases, you can check whether the pip module exists in the directory of the virtual environment, if it does not exist, the pip module can be installed in the specified directory; if it exists, it is not the problem of the pip module path, so what exactly is the reason?

After investigation, it is the problem of pip version, my Python version is 3.6, pip version is 21.3.1, this version of pip will definitely appear the problem, the solution is also very simple, the pip version can be downgraded to 20.2.4, operation method see the following program 2: Downgrade pip version. (It is not recommended to upgrade pip, because new versions of pip may have the same problem)

Solution 1 (recommended): install the third-party package using the terminal terminal

Click Terminal at the bottom of pycharm toolbar , as shown in the following figure:

enter the PIP install command to install the third-party package, as shown in the figure:

But this solution treats the symptom but not the root cause, the problem is not solved, only the installation of third-party packages by alternative methods, if you want to solve the problem at all, please see solution 2 below.

Solution 2 (fundamental solution): downgrade the PIP version

First, open a project using pycharm. If there is no Python environment, you need to create a virtual environment first, as shown in the following figure:

In file - Settings - Python interpreter, we can see that the version of PIP in Python virtual environment is 21.3.1. As shown in the figure below, we need to downgrade the version of Pip to 20.2.4

Click Terminal on the toolbar at the bottom of pychart, as shown in the following figure:

enter the following command. Note that there must be Python -m, otherwise there is no permission:

python -m pip install pip==20.2.4

After entering the command, the following prompt appears to prove that the downgrade is successful:

enter the command PIP - V to view the current PIP version, as shown in the following figure:

the problem has been successfully solved so far. The third-party package can be successfully installed in Settings, as shown in the following figure:

Read More:

Когда я создаю новый проект django в pycharm, у меня возникает ошибка
введите описание изображения здесь

Помогите мне, пожалуйста

Как вы видите, PyCharm дал вам «предлагаемое решение», так что используйте его.

По сути, PyCharm пытается добавить, или вы пытались добавить, аргумент --build-dir к команде pip, но pip не знает, что означает --build-dir.

Откройте терминал/командную строку, cd войдите в каталог проекта и запустите pip install django.

Откройте настройки Pycharm и перейдите к настройкам переводчика File->Settings->Project->Project Interpreter и click кнопку + справа, затем найдите django и
установите его.

Чтобы не делать проект в каталоге venv/Scripts/, добавьте путь во время выполнения django-admin startproject [project-name-that-you-want] [project-directory-path] этой команды.
Это позволит вам разместить ваш проект django в нужной вам директории, так что ваша директория проекта будет похожа на те, которые вы можете найти в обучающих видео.

Вернуться на верх

Add Answer
|
View In TPC Matrix

Technical Problem Cluster First Answered On
February 2, 2022

Popularity
4/10

Helpfulness
4/10


Contributions From The Grepper Developer Community

Contents

Code Examples

  • non-zero exit code (103) pycharm
  • Related Problems

  • non-zero exit code (2) pycharm
  • error: functions predeploy error: command terminated with non-zero exit code1
  • subprocess.check_output returned non-zero exit status 1
  • TPC Matrix View Full Screen

    non-zero exit code (103) pycharm

    Comment

    0


    Popularity

    4/10 Helpfulness
    4/10
    Language
    whatever

    Source: Grepper

    Tags: exit-code
    pycharm
    whatever

    Repulsive Reindeer

    Contributed on Feb 02 2022

    Repulsive Reindeer

    7 Answers  Avg Quality 6/10


    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии

    А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Nox brawl stars произошла ошибка
  • Novex стиральная машина ошибка е21