Pycharm ошибка при установке библиотеки

I have pycharm community edition(latest stable build) installed on my Ubuntu 16.04 LTS, I am not able to install packages via pycharm, was able to install them before. I can install the packages via pip, but would like to solve this issue.

Below is the Screenshot of the problem

enter image description here

Have googled for this issue, but could not find any fix, I have a windows machine and it does not face the same issue.

asked Oct 15, 2016 at 14:37

penta's user avatar

pentapenta

2,5064 gold badges24 silver badges50 bronze badges

2

I have got a solution, i reffered to https://youtrack.jetbrains.com/issue/PY-20081#u=1468410176856.

Here they have tried to add https://pypi.python.org/pypi as a repository.

To add it as a repository,

1.) Go to Settings
2.) Project interpreter
3.) Click the + sign on top right edge
4.) Go to manage repositories, 
5.) Press the + Sign, then add https://pypi.python.org/pypi
6.) Press Ok

Now all the packages should load.

Thanks Hami Torun & Simon, I was able to solve it by luck.

answered Oct 15, 2016 at 16:23

penta's user avatar

pentapenta

2,5064 gold badges24 silver badges50 bronze badges

3

I had the same issue. It happened suddenly, day ago I was able to perform pip or install packages but on the next day error appeared. However this helped (I used version PyCharm Community Edition 2018):

Go to Settings -> Project Interpreter -> click green «+» icon (on right) -> Manage Repositories (on bottom) -> delete https://pypi.python.org/simple -> add https://pypi.python.org/pypi
then click Ok. Repo will be back again as /simple, but don’t worry, error should disappear and you should be able to install packages again.

answered May 2, 2018 at 14:58

Belloz's user avatar

BellozBelloz

4235 silver badges9 bronze badges

2

For me, it was because of low space in my pc. After I free up space the problem solved. Pycharm did not say anything about this problem. It just shows that «the package installed successfully», but actually package was not installed.

answered Apr 15, 2019 at 19:52

saleh sereshki's user avatar

saleh sereshkisaleh sereshki

2,3823 gold badges16 silver badges18 bronze badges

I just had a similar problem.
My project was created by PyCharm, with venv.
The package I was installing via manager (Ctrl+Alt+S), was showing in the list, but it wasn’t being recognized or imported.

I believe the error happened because I tried to install it before, using pip install into IDE’s own terminal. Also pip version in the manager was a beta version, then I changed it to a stable version.

Had to start a new project in a new folder.

answered Nov 2, 2020 at 0:20

Marcelo Assis's user avatar

Marcelo AssisMarcelo Assis

5,1363 gold badges33 silver badges54 bronze badges

The accepted answer didn’t work for me. I had to update my pip version from the PyCharm terminal:

pip install --upgrade pip

answered Dec 3, 2020 at 23:46

ezra buchla's user avatar

ezra buchlaezra buchla

3192 silver badges6 bronze badges

enter image description here

I installed PyCharm and and Python 3 using the zip file. Now I want to install various libraries but it would not allow me to do so. How should I install the libraries on PyCharm?

asked Jun 19, 2018 at 20:02

JungleDiff's user avatar

i think you need to install setuptools

sudo apt-get install python3-setuptools

answered Jun 19, 2018 at 20:04

Druta Ruslan's user avatar

Druta RuslanDruta Ruslan

7,1212 gold badges28 silver badges38 bronze badges

Important Step:

Open Command Prompt in Windows
And Type pip install python3-setuptools

If First Step is throwing some Error

To solve this,you need to let python know where the pip packages are to do this follow the instructions below

First Go to Settings and select Project interpreter, now Click on Add button and switch to manage repositories option and now again press add button and type
https://pypi.python.org/pypi in the box and save.

Now Restart your pycharm and it will work.

answered Jun 19, 2018 at 20:09

SaiKiran's user avatar

SaiKiranSaiKiran

6,16410 gold badges42 silver badges76 bronze badges

6

Сделал это, запустил через терминал. Вот код

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import face-recognition #пробовал и face_recognition
import cv2
import numpy as np
import os
from datetime import datetime
 
path = 'KnownFaces'
images = []
classNames = []
myList = os.listdir(path)
print(myList)
 
for cls in myList:
    curImg = cv2.imread(f'{path}/{cls}')
    images.append(curImg)
    classNames.append(os.path.splitext(cls)[0])
 
print(classNames)
 
def findEncodings(images):
    encodeList = []
    for img in images:
        img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        encode = face_recognition.face_encodings(img)[0]
        encodeList.append(encode)
    return encodeList
 
def markAttendance(name):
    with open("Attendance.csv", "r+") as f:
        myDataList = f.readlines()
        nameList = []
        for line in myDataList:
            entry = line.split(',')
            nameList.append(entry[0])
        if name not in nameList:
            now = datetime.now()
            dtString = now.strftime("%H:%M:%S")
            f.writelines(f'n{name}, {dtString}')
 
encodeListKnown = findEncodings(images)
print("Декодирование закончено")
 
cap = cv2.VideoCapture(0)
 
while True:
    success, img = cap.read()
    imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25)
    imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
 
    facesCurFrame = face_recognition.face_locations(imgS)
    encodeCurFrame = face_recognition.face_encodings(imgS, facesCurFrame)
 
    for encodeFace, faceLoc in zip(encodeCurFrame, facesCurFrame):
        matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
        faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
        #print(faceDis)
        matchIndex = np.argmin(faceDis)
 
        if matches[matchIndex]:
            name = classNames[matchIndex]
            #print(name)
            y1, x2, y2, x1 = faceLoc
            y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
            cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
            cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
            cv2.putText(img, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
            markAttendance(name)
 
    cv2.imshow("WebCam", img)
    cv2.waitKey(1)

Выводит следующее:

Код

import face-recognition
  File "<stdin>", line 1
    import face-recognition
               ^
SyntaxError: invalid syntax
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>> import os
>>> from datetime import datetime
>>>
>>> path = 'KnownFaces'
>>> images = []
>>> classNames = []
>>> myList = os.listdir(path)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [WinError 3] Системе не удается найти указанный путь: 'KnownFaces'
>>> print(myList)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'myList' is not defined
>>>
>>> for cls in myList:
...     curImg = cv2.imread(f'{path}/{cls}')
...     images.append(curImg)
...     classNames.append(os.path.splitext(cls)[0])
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'myList' is not defined
>>> print(classNames)
[]
>>>
>>> def findEncodings(images):
...     encodeList = []
...     for img in images:
...         img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
...         encode = face_recognition.face_encodings(img)[0]
...         encodeList.append(encode)
...     return encodeList
...
>>> def markAttendance(name):
...     with open("Attendance.csv", "r+") as f:
...         myDataList = f.readlines()
...         nameList = []
...         for line in myDataList:
...             entry = line.split(',')
...             nameList.append(entry[0])
...         if name not in nameList:
...             now = datetime.now()
...             dtString = now.strftime("%H:%M:%S")
...             f.writelines(f'n{name}, {dtString}')
...
>>> encodeListKnown = findEncodings(images)
>>> print("Декодирование закончено")
Декодирование закончено
>>>
>>> cap = cv2.VideoCapture(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'cv2' is not defined
>>>
>>> while True:
...     success, img = cap.read()
...     imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25)
...     imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'cap' is not defined
>>>     facesCurFrame = face_recognition.face_locations(imgS)
  File "<stdin>", line 1
    facesCurFrame = face_recognition.face_locations(imgS)
IndentationError: unexpected indent
>>>     encodeCurFrame = face_recognition.face_encodings(imgS, facesCurFrame)
  File "<stdin>", line 1
    encodeCurFrame = face_recognition.face_encodings(imgS, facesCurFrame)
IndentationError: unexpected indent
>>>
>>>     for encodeFace, faceLoc in zip(encodeCurFrame, facesCurFrame):
  File "<stdin>", line 1
    for encodeFace, faceLoc in zip(encodeCurFrame, facesCurFrame):
IndentationError: unexpected indent
>>>         matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
  File "<stdin>", line 1
    matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
IndentationError: unexpected indent
>>>         faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
  File "<stdin>", line 1
    faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
IndentationError: unexpected indent
>>>         #print(faceDis)
>>>         matchIndex = np.argmin(faceDis)
  File "<stdin>", line 1
    matchIndex = np.argmin(faceDis)
IndentationError: unexpected indent
>>>
>>>         if matches[matchIndex]:
  File "<stdin>", line 1
    if matches[matchIndex]:
IndentationError: unexpected indent
>>>             name = classNames[matchIndex]
  File "<stdin>", line 1
    name = classNames[matchIndex]
IndentationError: unexpected indent
>>>             #print(name)
>>>             y1, x2, y2, x1 = faceLoc
  File "<stdin>", line 1
    y1, x2, y2, x1 = faceLoc
IndentationError: unexpected indent
>>>             y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
  File "<stdin>", line 1
    y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
IndentationError: unexpected indent
>>>             cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
  File "<stdin>", line 1
    cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
IndentationError: unexpected indent
>>>             cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
  File "<stdin>", line 1
    cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
IndentationError: unexpected indent
>>>             cv2.putText(img, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
  File "<stdin>", line 1
    cv2.putText(img, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
IndentationError: unexpected indent
>>>             markAttendance(name)
  File "<stdin>", line 1
    markAttendance(name)
IndentationError: unexpected indent
>>>
>>>     cv2.imshow("WebCam", img)
  File "<stdin>", line 1
    cv2.imshow("WebCam", img)
IndentationError: unexpected indent
>>>     cv2.waitKey(1)

ОШИБКА ПОЧТИ В КАЖДОЙ СТРОЧКЕ! Но я так понимаю что это из-за неподключённых библиотек, ведь так? Можете пожалуйста скинуть рабочий код для распознавания лиц в google colab’e?



0



Не понимаю, почему pycharm не видит библиотеки при импорте, хоть их установка через консоль проходит успешно. Допустим, я устанавливаю библиотеку speech_recognition через терминал(используя pip), установка проходит успешно, но при попытке импортировать библиотеку, появляется ошибка: «ModuleNotFoundError: No module named ‘speech_recognition'». После я устанавливаю эту библиотеку через менеджер пакетов, теперь ее видно, но не хватает библиотеки pyAudio. При установке pyAudio через консоль, библиотеки также не видно, а при установке pyAudio через менеджер появляется ошибка, связанная именно с самим пакетом. И по такой же схеме со всеми библиотеками, только названия меняются, поэтому не могу с ними работать, что мне делать?


  • Вопрос задан

    более года назад

  • 9872 просмотра

import face-recognition
  File "<stdin>", line 1
    import face-recognition
               ^
SyntaxError: invalid syntax
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>> import os
>>> from datetime import datetime
>>>
>>> path = 'KnownFaces'
>>> images = []
>>> classNames = []
>>> myList = os.listdir(path)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [WinError 3] Системе не удается найти указанный путь: 'KnownFaces'
>>> print(myList)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'myList' is not defined
>>>
>>> for cls in myList:
...     curImg = cv2.imread(f'{path}/{cls}')
...     images.append(curImg)
...     classNames.append(os.path.splitext(cls)[0])
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'myList' is not defined
>>> print(classNames)
[]
>>>
>>> def findEncodings(images):
...     encodeList = []
...     for img in images:
...         img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
...         encode = face_recognition.face_encodings(img)[0]
...         encodeList.append(encode)
...     return encodeList
...
>>> def markAttendance(name):
...     with open("Attendance.csv", "r+") as f:
...         myDataList = f.readlines()
...         nameList = []
...         for line in myDataList:
...             entry = line.split(',')
...             nameList.append(entry[0])
...         if name not in nameList:
...             now = datetime.now()
...             dtString = now.strftime("%H:%M:%S")
...             f.writelines(f'n{name}, {dtString}')
...
>>> encodeListKnown = findEncodings(images)
>>> print("Декодирование закончено")
Декодирование закончено
>>>
>>> cap = cv2.VideoCapture(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'cv2' is not defined
>>>
>>> while True:
...     success, img = cap.read()
...     imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25)
...     imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'cap' is not defined
>>>     facesCurFrame = face_recognition.face_locations(imgS)
  File "<stdin>", line 1
    facesCurFrame = face_recognition.face_locations(imgS)
IndentationError: unexpected indent
>>>     encodeCurFrame = face_recognition.face_encodings(imgS, facesCurFrame)
  File "<stdin>", line 1
    encodeCurFrame = face_recognition.face_encodings(imgS, facesCurFrame)
IndentationError: unexpected indent
>>>
>>>     for encodeFace, faceLoc in zip(encodeCurFrame, facesCurFrame):
  File "<stdin>", line 1
    for encodeFace, faceLoc in zip(encodeCurFrame, facesCurFrame):
IndentationError: unexpected indent
>>>         matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
  File "<stdin>", line 1
    matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
IndentationError: unexpected indent
>>>         faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
  File "<stdin>", line 1
    faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
IndentationError: unexpected indent
>>>         #print(faceDis)
>>>         matchIndex = np.argmin(faceDis)
  File "<stdin>", line 1
    matchIndex = np.argmin(faceDis)
IndentationError: unexpected indent
>>>
>>>         if matches[matchIndex]:
  File "<stdin>", line 1
    if matches[matchIndex]:
IndentationError: unexpected indent
>>>             name = classNames[matchIndex]
  File "<stdin>", line 1
    name = classNames[matchIndex]
IndentationError: unexpected indent
>>>             #print(name)
>>>             y1, x2, y2, x1 = faceLoc
  File "<stdin>", line 1
    y1, x2, y2, x1 = faceLoc
IndentationError: unexpected indent
>>>             y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
  File "<stdin>", line 1
    y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
IndentationError: unexpected indent
>>>             cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
  File "<stdin>", line 1
    cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
IndentationError: unexpected indent
>>>             cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
  File "<stdin>", line 1
    cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
IndentationError: unexpected indent
>>>             cv2.putText(img, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
  File "<stdin>", line 1
    cv2.putText(img, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
IndentationError: unexpected indent
>>>             markAttendance(name)
  File "<stdin>", line 1
    markAttendance(name)
IndentationError: unexpected indent
>>>
>>>     cv2.imshow("WebCam", img)
  File "<stdin>", line 1
    cv2.imshow("WebCam", img)
IndentationError: unexpected indent
>>>     cv2.waitKey(1)

  • Python try except несколько ошибок
  • Pycharm ошибка не удается найти указанный файл
  • Python try except как вывести текст ошибки
  • Pycharm ошибка интерпретатора python
  • Python try except как вывести ошибку