Get a List of Keys From a Dictionary in Both Python 2 and Python 3

本文详细介绍了在Python3环境下安装MySQL Connector的具体步骤,包括如何使用virtualenv创建Python3虚拟环境,激活环境并使用pip3安装MySQL Connector。解决在Ubuntu上安装Python3库的常见问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://askubuntu.com/questions/656610/trying-to-install-mysql-connector-for-python-3?rq=1

my experience is minimal with Linux so i need a little help!

i am trying to install the python mysql-connector for python3.2, i was able to use pip to install it for python2.7 with 'pip install mysql-connector'. To install it for python 3 i believe you have to use the python3 pip instead of the python2 pip, i read that somewhere but im not sure if its correct, does the python3 pip know to get the correct connector or do you have to specify the specific version like 'pip install mysql-connector1.2'.

anyways, i was finding it difficult to get the py3 pip, then i came across a post advising the use of 'virtualenv' to make it easier to work with different versions of python. This post:

How to install pip for python 3 in ubuntu 12.04 LTS

says to create the virtual environment, activate it and then proceed to pip install whatever package you need. however, when i get as far as pip install it doesnt seem to get the mysql-connector that i need, and running 'pip --version' from inside the virtualenv it tells me that the python2.7 pip is being used.

i've tried other things to try get pip3 such as 'easy-install pip3' which doesnt seem to work either.

Is this the only route to take to get the correct mysql-connector? or is there another way i can get pip3 (for py3.2)?

thanks, any advice greatly appreciated!

share improve this question
 

3 Answers

up vote 1down voteaccepted

Ah! The problem you seem to be facing is you can't create virtualenv with python3.

And to install dependencies for python3 environment you run pip3 install package-name

Follow these steps for creating virtualenv in python3 environment:

virtualenv -p /usr/bin/python3 yourenv source yourenv/bin/activate pip3 install mysql-connector

转载于:https://www.cnblogs.com/kungfupanda/p/5779870.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值