ไม่สามารถ pip ติดตั้ง mysqlclient และดำเนินการ 'gcc': การอนุญาตถูกปฏิเสธ

ขออภัยหากฉันถามอะไรง่ายๆ

ฉันกำลังตั้งค่าแอป Django บนเซิร์ฟเวอร์ระยะไกลโดย Namecheap (ไม่มีการเข้าถึงรูท)

และข้อมูลเซิร์ฟเวอร์ของฉัน:

อาปาเช่เวอร์ชัน: 2.4.38

เวอร์ชัน MySQL: 10.1.38-MariaDB-cll-lve

สถาปัตยกรรม: x86_64

ระบบปฏิบัติการ: ลินุกซ์

หลาม: 3.7

จังโก้: 2.1.7

ตอนนี้ฉันกำลังพยายามให้ฐานข้อมูล mysql เชื่อมต่อกับแอป django ของฉัน

แต่เมื่อฉันลองติดตั้งตัวเชื่อมต่อ mysqlclient ด้วย pip install mysqlclient

ฉันมีข้อผิดพลาดนี้:

  $ pip install mysqlclient
  Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient ... error
  Complete output from command /home/letsilap/virtualenv/IOT/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_19o3wdf/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp45bylejwpip-wheel- --python-tag cp37:
  /opt/alt/python37/lib64/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
  copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
  creating build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/MySQLdb
  gcc -pthread -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/include/mysql -I/usr/include/mysql/.. -I/opt/alt/python37/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
  unable to execute 'gcc': Permission denied
  error: command 'gcc' failed with exit status 1


  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command /home/letsilap/virtualenv/IOT/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_19o3wdf/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v39up5s1-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/letsilap/virtualenv/IOT/3.7/include/site/python3.7/mysqlclient:
    /opt/alt/python37/lib64/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
    creating build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/MySQLdb
    gcc -pthread -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/include/mysql -I/usr/include/mysql/.. -I/opt/alt/python37/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
    unable to execute 'gcc': Permission denied
    error: command 'gcc' failed with exit status 1
    Command "/home/letsilap/virtualenv/IOT/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_19o3wdf/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v39up5s1-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/letsilap/virtualenv/IOT/3.7/include/site/python3.7/mysqlclient" failed with error code 1 in /tmp/pip-build-_19o3wdf/mysqlclient/

ฉันดำดิ่งลงสู่ข้อความแสดงข้อผิดพลาด (เข้าใจ)

unable to execute 'gcc': Permission denied
error: command 'gcc' failed with exit status 1

ดูเหมือนว่าจะแสดงว่าข้อผิดพลาดนั้นขึ้นอยู่กับการอนุญาตของระบบ luinx

ไม่มีใครรู้วิธีการแก้ปัญหานี้หรือไม่? สูงฝึกหัด


person Rookies DJ    schedule 03.04.2019    source แหล่งที่มา
comment
ดูเหมือนว่าไม่เพียงแต่คุณเท่านั้นที่สามารถเข้าถึงรูทได้ แต่คุณไม่สามารถเข้าถึงคอมไพเลอร์ได้ (และน่าจะเป็นไปได้มากสำหรับเครื่องมือการพัฒนาอื่น ๆ ) คุณไม่สามารถติดตั้งโมดูล Python ได้หากไม่ได้รับความช่วยเหลือจากผู้ดูแลระบบ   -  person phd    schedule 03.04.2019


คำตอบ (2)


ไม่สามารถดำเนินการ 'gcc': การอนุญาตถูกปฏิเสธ

หมายความว่าผู้ใช้ของคุณไม่ได้รับอนุญาตให้เรียกใช้คอมไพเลอร์ gcc C

นี่ถือเป็นเรื่องปกติ และดูเหมือนเป็นมาตรการรักษาความปลอดภัย (เข้มงวดเล็กน้อย) บนเซิร์ฟเวอร์ที่คุณใช้อยู่ คุณจะต้องถามใครก็ตามที่ดูแลเซิร์ฟเวอร์เพื่อขอความช่วยเหลือ

person AKX    schedule 11.04.2019

คุณต้องมีสิทธิ์รูทจึงจะสามารถรันคำสั่งประเภทนี้ได้ เพิ่ม sudo ในคำสั่งของคุณ:

sudo pip install mysqlclient
person Mojtaba Kamyabi    schedule 03.04.2019
comment
ฉันขอโทษปืนลูกซอง แต่ฉันไม่มีสิทธิ์เข้าถึงรูท - person Rookies DJ; 03.04.2019
comment
ลองสิ่งนี้: stackoverflow .com/questions/7465445/ - person jfleach; 03.04.2019
comment
@RookiesDJ. pip install --user mysqlclient ล้มเหลวเช่นกันใช่ไหม - person Mojtaba Kamyabi; 03.04.2019
comment
ใช่ ฉันได้รับข้อผิดพลาดนี้ ไม่สามารถทำการติดตั้ง '--user' ได้ แพ็คเกจไซต์ของผู้ใช้ไม่สามารถมองเห็นได้ใน virtualenv นี้ - person Rookies DJ; 04.04.2019