没有名为';mysql';python问题

没有名为';mysql';python问题,python,python-3.x,mysql-python,python-3.7,Python,Python 3.x,Mysql Python,Python 3.7,我正在尝试创建一个示例python程序,它需要连接到MySQL数据库 import mysql.connector # opens the file file.txt in read mode fileptr = open("sample-table","r") if fileptr: print("file is opened successfully") #running a for loop for i in fileptr: print(i)

我正在尝试创建一个示例python程序,它需要连接到MySQL数据库

import mysql.connector 

# opens the file file.txt in read mode
fileptr = open("sample-table","r")  

if fileptr:  
    print("file is opened successfully") 

#running a for loop   
for i in fileptr:  
    print(i) # i contains each line of the file 

#closes the opened file  
fileptr.close()
但我得到了这个错误

Traceback (most recent call last):
  File "check-db.py", line 1, in <module>
    import mysql.connector 
ModuleNotFoundError: No module named 'mysql'
回溯(最近一次呼叫最后一次):
文件“check db.py”,第1行,在
导入mysql.connector
ModuleNotFoundError:没有名为“mysql”的模块
看起来所需的模块不存在。是否可以在没有root访问权限的情况下包含和安装模块?

按如下方式安装pip:

apt install python-pip  #python 2
apt install python3-pip #python 3
尝试使用以下命令安装mysql:

pip install pymysql

我得到的错误是
[username@archlinux~]$pip安装pymysql bash:pip:command未找到
然后使用这个:
python-m pip安装pymysql
感谢您的回复。我再次收到错误,因为
/usr/bin/python:没有名为pip的模块尝试安装pip,但是再次出现错误
sudopacman-spython3pip错误:未找到目标:python3pip
关于
sudopacman-spython2pip
的情况如何?您使用的是python3还是Python2?也许这对@markkeven有帮助,我可以下载它,但安装它需要root权限。我正在寻找解决方案,以包括mysql没有根,这不是什么虚拟环境的目的吗?您应该能够使用它们在本地安装东西,而不需要额外的权限。