Non-zero exit code (1) - unable to install packages in pycharm

已回答

i am unable to install any package!

i get the error:

Non-zero exit code (1)

0

Have you tried doing it outside of PyCharm?
Most likely there is some issue with pip or environment.

Anyway, sharing the whole Traceback or at least a screenshot is better than just an exit code.

0
Avatar
Permanently deleted user

I'm a newbie and I have what may be a similar problem.  I've been using pyCharm community 2019.2.3 on my desktop for a few weeks and written a simple script to get a bunch of files from an SFTP server.  I just installed the same version of pyCharm on a laptop but I can't get it to install the pysftp package in it's venv.  Installed ok using cmd window but not recognised in pyCharm.  I'm a bit lost.  This is the traceback I get trying to install from the pyCharm terminal...

(venv) C:\Users\TPIO\PycharmProjects\TPIO>pip install pysftp
Collecting pysftp
Using cached https://files.pythonhosted.org/packages/36/60/45f30390a38b1f92e0a8cf4de178cd7c2bc3f874c85430e40ccf99df8fe7/pysftp-0.2.9.tar.gz
Collecting paramiko>=1.17 (from pysftp)
Using cached https://files.pythonhosted.org/packages/4b/80/74dace9e48b0ef923633dfb5e48798f58a168e4734bca8ecfaf839ba051a/paramiko-2.6.0-py2.py3-none-any.whl
Collecting pynacl>=1.0.1 (from paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/61/ab/2ac6dea8489fa713e2b4c6c5b549cc962dd4a842b5998d9e80cf8440b7cd/PyNaCl-1.3.0.tar.gz (3.4MB)
100% |████████████████████████████████| 3.4MB 2.4MB/s
Installing build dependencies ... error
Complete output from command C:\Users\TPIO\PycharmProjects\TPIO\venv\Scripts\python.exe C:\Users\TPIO\PycharmProjects\TPIO\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip install --ignore
-installed --no-user --prefix C:\Users\TPIO\AppData\Local\Temp\pip-build-env-cha8mv4c\overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --
setuptools wheel "cffi>=1.4.1; python_implementation != 'PyPy'":
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/6a/9a/50fadfd53ec909e4399b67c74cc7f4e883488035cfcdb90b685758fa8b34/setuptools-41.4.0-py2.py3-none-any.whl
Collecting wheel
Using cached https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl
Collecting cffi>=1.4.1
Using cached https://files.pythonhosted.org/packages/0d/aa/c5ac2f337d9a10ee95d160d47beb8d9400e1b2a46bb94990a0409fe6d133/cffi-1.13.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "C:\Users\TPIO\PycharmProjects\TPIO\venv\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
return self.find_available_vc_vers()[-1]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\TPIO\AppData\Local\Temp\pip-install-d9ln2ikw\cffi\setup.py", line 127, in <module>
if sys.platform == 'win32' and uses_msvc():
File "C:\Users\TPIO\AppData\Local\Temp\pip-install-d9ln2ikw\cffi\setup.py", line 105, in uses_msvc
return config.try_compile('#ifndef _MSC_VER\n#error "not MSVC"\n#endif')
File "C:\Users\TPIO\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\config.py", line 225, in try_compile
self._compile(body, headers, include_dirs, lang)
File "C:\Users\TPIO\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\config.py", line 132, in _compile
self.compiler.compile([src], include_dirs=include_dirs)
File "C:\Users\TPIO\AppData\Local\Programs\Python\Python38-32\lib\distutils\_msvccompiler.py", line 360, in compile
self.initialize()
File "C:\Users\TPIO\AppData\Local\Programs\Python\Python38-32\lib\distutils\_msvccompiler.py", line 253, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\Users\TPIO\PycharmProjects\TPIO\venv\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
File "C:\Users\TPIO\PycharmProjects\TPIO\venv\lib\site-packages\setuptools\msvc.py", line 843, in __init__
self.si = SystemInfo(self.ri, vc_ver)
File "C:\Users\TPIO\PycharmProjects\TPIO\venv\lib\site-packages\setuptools\msvc.py", line 485, in __init__
self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
File "C:\Users\TPIO\PycharmProjects\TPIO\venv\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
raise distutils.errors.DistutilsPlatformError(err)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\TPIO\AppData\Local\Temp\pip-install-d9ln2ikw\cffi\

----------------------------------------
Command "C:\Users\TPIO\PycharmProjects\TPIO\venv\Scripts\python.exe C:\Users\TPIO\PycharmProjects\TPIO\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip install --ignore-installed --no-user -
-prefix C:\Users\TPIO\AppData\Local\Temp\pip-build-env-cha8mv4c\overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel "cff
i>=1.4.1; python_implementation != 'PyPy'"" failed with error code 1 in None

 

Most of it is meaningless to me and I'm confused as to why my venv doesn't already include pysftp as I installed it before I installed pyCharm.  Like I said - newbie :-(  Output from pip list below.

Package Version
------------ -------
bcrypt 3.1.7
cffi 1.13.1
cryptography 2.8
paramiko 2.6.0
pip 19.3.1
pycparser 2.19
PyNaCl 1.3.0
pysftp 0.2.9
setuptools 41.2.0
six 1.12.0

One last thing - my script works fine when I execute it from the command line.  I just can't "use" it in pyCharm because it won't import pysftp.

0

@Ianpigney

I suspect you are using a different interpreter in the command line. That would explain why you can use pysftp when running the script from the command line and can't when running from PyCharm.

So either use in PyCharm the same interpreter you use in the command line or fix the issue with your virtualenv and install it there.

0
Avatar
Permanently deleted user

Thanks.

I've been trying to find a way to "fix the issue" with the venv with no luck.  In the end I created a new project, ticked the box that says something like "use global packages in venv" and the one that says "make available to other projects" then changed my original project over to that new interpreter.  All fixed.

5
Avatar
Permanently deleted user

^ This actually helped me, someone gives this man a medal please. 5 hours stuck with 'can't install PEP XXX something' 

1
Avatar
Permanently deleted user

I created an account just to thank Ianpigney , thank you

1

My solution: If you install Python from official website, IntelliJ detects the installation path like the Python App from Microsoft Store. You should to change the path to the official Python installation (c:\users\%USERNAME%\AppData\Local\Programs\Python\Python39 for example)

0
Avatar
Permanently deleted user

i get the same error

Non-zero exit code (2)

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 '/Users/miguelmarengo/PycharmProjects/pythonProject3/venv/bin/python'.

in the terminal i use "python -m pip install pandas" IT DOES WORK.....but hove do i resolve this issue NOT TYPING this in the Terminal....before used to work fine

0

The problem is known https://youtrack.jetbrains.com/issue/PY-45712 and already fixed. We will add a fix to the next update.

As a workaround, you can downgrade pip to 20.2.4 or use the terminal for installing packages.

 

To downgrade pip on Windows, close PyCharm and run `python -m pip install pip==20.2.4`. Make sure you use the same python executable as in PyCharm or activated the same venv.

 

I'm sorry for the inconvenience.

1

I am encountering the same issue. The module (beautifulsoup4) exists in my user packages. Oddly enough, no issues upgrading pip through the Pycharm interface under project python interpreter (screenshot below. Note: I am using the current version of pip, and have the most recent PyCharm Pro installed. 2020.2 built 25 Nov 2020)

Error details:

Usage:
/home/dglenn/Projects/venv/bin/python -m pip install [options] <requirement specifier> [package-index-options] ...
/home/dglenn/Projects/venv/bin/python -m pip install [options] -r <requirements file> [package-index-options] ...
/home/dglenn/Projects/venv/bin/python -m pip install [options] [-e] <vcs project url> ...
/home/dglenn/Projects/venv/bin/python -m pip install [options] [-e] <local project path> ...
/home/dglenn/Projects/venv/bin/python -m pip install [options] <archive url/path> ...

no such option: --build-dir

(/error)

Message returned installing outside PyCharn in a terminal:

(venv) dglenn@Izabell:~/Projects/venv$ pip install beautifulsoup4
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: beautifulsoup4 in /home/dglenn/.local/lib/python3.8/site-packages (4.9.1)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.8/dist-packages (from beautifulsoup4) (2.0)

(/message)

The bin content contains links to current system executables in /usr/bin, so all binary files in venv/bin match the system python.

screenshot of currently installed packages in venv:

0

By the way, the link https://youtrack.jetbrains.com/issues/PY is enountering server errors so I could not submit a ticket in the tracker. Error says you need to view the log for the error. (The error message that pops up is so fast I had to duplicate the steps 4 times before i could discern the error message)

0

Your virtual python version in venv doesn't match installed python version in system. Install appropriate python version. 

0

请先登录再写评论。