How do you install mysql-connector-python (development version) through pip?

原文链接:http://www.cnblogs.com/kungfupanda/p/5877880.html

http://stackoverflow.com/questions/31748278/how-do-you-install-mysql-connector-python-development-version-through-pip/34027037#34027037

 

I have a virtualenv in which I am running Django 1.8 with Python 3.4

I am trying to get support for MySQL however I am having trouble getting the different connectors to work. I have always used mysql-connector-python with django 1.7 and would like to continue using it.

The development version of mysql-connector-python (2.1.2) seems to have support for Django 1.8 now.

How do I install the development version using pip install (within my virtualenv)? I have tried running the following command:

pip install mysql-connector-python==2.1.2 --allow-external mysql-connector-python

but the 2.1.2 developer version is not available there:

could not find a version that satisfies the requirement mysql-connector-python==2.1.2 (from versions: 1.1.4, 1.1.5, 1.1.6, 1.2.2, 1.2.3, 2.0.1, 2.0.2, 2.0.3, 2.0.4)
  Some insecure and unverifiable files were ignored (use --allow-unverified mysql-connector-python to allow).
No matching distribution found for mysql-connector-python==2.1.2

I have tried downloading the file directly from: http://dev.mysql.com/downloads/connector/python/

...but for some reason after installation the connector is not available within my virtualenv

Help please :-) Thank you. '

EDIT: I have tried  pip install mysql-python but it is not supported by Python 3.4

share|improve this question
 
   

1 Answer                                 1

         up vote27down vote

I agree, the debian packages appear to be broken for at least Ubuntu 14.04.

The apt-get version and the pip version do not include the 2.1.x releases.

To get it done, I had to grab the source:

$  git clone https://github.com/mysql/mysql-connector-python.git
$  cd mysql-connector-python
$  python ./setup.py build
$  sudo python ./setup.py install

...

>>> import mysql.connector as msc
>>> msc.__version__
'2.1.3'
>>>

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

展开阅读全文
博主设置当前文章不允许评论。

How Long Do You Have to Draw

10-28

Problem DescriptionnThere are two horizontal lines on the XoY plane. One is y1 = a, the other is y2 = b(a < b). On line y1, there are N points from left to right, the x-coordinate of which are x = c1, c2, ... , cN (c1 < c2 < ... < cN) respectively. And there are also M points on line y2 from left to right. The x-coordinate of the M points are x = d1, d2, ... dM (d1 < d2 < ... < dM) respectively.nNow you can draw segments between the points on y1 and y2 by some segments. Each segment should exactly connect one point on y1 with one point on y2.nThe segments cannot cross with each other. By doing so, these segments, along with y1 and y2, can form some triangles, which have positive areas and have no segments inside them.nThe problem is, to get as much triangles as possible, what is the minimum sum of the length of these segments you draw?n nnInputnThe first line has a number T (T <= 20) , indicating the number of test cases.nFor each test case, first line has two numbers a and b (0 <= a, b <= 104), which is the position of y1 and y2.nThe second line has two numbers N and M (1 <= N, M <= 105), which is the number of points on y1 and y2.nThe third line has N numbers c1, c2, .... , cN(0 <= ci < ci+1 <= 106), which is the x-coordinate of the N points on line y1.nThe fourth line has M numbers d1, d2, ... , dM(0 <= di < di+1 <= 106), which is the x-coordinate of the M points on line y2.n nnOutputnFor test case X, output "Case #X: " first, then output one number, rounded to 0.01, as the minimum total length of the segments you draw.n nnSample Inputn1n0 1n2 3n1 3n0 2 4n nnSample OutputnCase #1: 5.66 问答

What do you do for Singleton?

06-20

I see many programmers do singleton like:rnclass Singleton implements Irnstatic Singleton _inst = null;rnstatic I getInstance()if(_inst==null)_inst = new Singleton();return _instrnrnrnWell, it works.rnBut, think hard. why wouldn't you dornclass Singleton implements Irnstatic final Singleton _inst=new Singleton();rnstatic I getInstance()return _inst;rnrn?rnMuch simpler, right?rnrnMany programmers would say: "the first one is lazy initialization. So should be better."rnrnReally? by using the first one, what do you save? a Singleton object, right? rnrnBut how big is that? From my experience, a singleton is normally quite small. For a small object with 10-20 bytes, is it worthy the extra code "if(......)"? rnthe extra code will not use memory space anyway? rnand it makes your code unnecessarily more complicated.rnrndoes it worth the extra runtime overhead to check the reference everytime the getInstance() is called?rnrnAlso, programmer often ignore the thread-safety of the first approach.rnrnWhat if there are threads calling getInstance() concurrently? Do you need to place "synchronized" on your getInstance()? rnAnd if you place "synchronized", you may also feel uncomfortable because even for non-concurrent usage of your Singleton, you are also paying the locking overhead for each call against getInstance(). Painful!rnrnOf course, for big object, the lazy intialization is certainly useful. But, there's still another approach you may want to consider if the memory space for this big object is really something.rnrnthink about this: if every user of the singleton has finished using this singleton, do I still need to hold this object? Can I reclaim the memory space for it?rnrnThen, you may want to use WeakReference to further optimize it.rnrnfor example:rnrnclass Singleton implements Irnstatic WeakReference _inst = null;rnstatic I getInstance()rnrnif(_inst==null || _inst.get()==null)rn _inst = new WeakReference(new Singleton());rnreturn (I)_inst.get();rnrnrnrnIt works? rnWell, looks like. But no!rn(I give this wrong demo to show that sometimes introducing more code is probably introducing more chances to get bug.)rnrnYou may just return "null" sometimes. This is because of the WeakReference! It does not guarantee to hold the new Singleton instance for you.rnrnSo, a possible version would be:rnclass Singleton implements Irn static WeakReference _inst = null;rn rn static synchronized I getInstance()rn rn I ret;rn if(_inst==null)rn ret = new Singleton();rn _inst = new WeakReference(ret);rn rn elsern rn ret = (I)_inst.get();rn if(ret == null)rn ret = new Singleton();rn _inst = new WeakReference(ret);rn rn rn return ret;rn rnrnquite something to do!rn 论坛

Would you tell me how to do ? [SOS] C++ ->ASM

11-07

我想将下面程式中的init_port和send_port改成汇编。但我不识汇编,你能帮个忙吗?因我在Delphi 5.x开发了一个系统,在Delphi 5.x可使用ASM。rnrn#include rn#include rn#include rn#include rn#include rnrnvoid init_port(code)rnunsigned char code;rnrn union REGS r;rn rn r.x.dx = 0; /* com1 */ rn r.h.ah = 0; rn r.h.al = code;rn int86(0x14,&r,&r);rnrnrnvoid send_port(c)rnchar c;rnrn union REGS r;rnrn r.x.dx = 0; /* com1 */rn r.h.al = c;rn r.h.ah = 1;rn int86(0x14,&r,&r);rn if (r.h.ah & 128) rn printf("send error !\n");rn exit(-1);rn rnrnrn/************************/rnvoid setmode(mode)rnint mode;rnrn send_port(27);rn if (mode==1) send_port(17); /* mode 1: overwrite mode */rn if (mode==2) send_port(18); /* mode 2: overwrite mode */rn if (mode==3) send_port(19); /* mode 3: overwrite mode */rnrnrnvoid cleardisplay()rnrn send_port(12);rnrnrnvoid initdisplay()rnrn send_port(27);rn send_port(64);rnrnrnvoid writestring(cc)rnchar *cc;rnrn int i,len;rnrn len=strlen(cc);rnrn send_port(27);rn send_port(81);rn send_port(65);rn for (i=0;i<=len;i++) rn send_port(toascii(cc[i]));rn rn send_port(13);rnrnrnvoid setstatus(s1,s2,s3,s4,s5)rnint s1,s2,s3,s4,s5;rnrn send_port(27);rn send_port(81);rn send_port(67);rn send_port(s1+0x30);rn send_port(s2+0x30);rn send_port(s3+0x30);rn send_port(s4+0x30);rn send_port(s5+0x30);rnrn send_port(13);rnrnrnvoid setpoint(k,n)rnint k,n; /* n=1 On, n=0 Off 1=0;i--) rn setpoint(i,1);rn delay(1500);rn setpoint(i,0);rn rn printf("clear screen and display '888888888888' !\n");rn printf("cursor to home and 5 kinds of status LED on, press any key\n");rn getch();rn cleardisplay();rn cursorhome();rn writestring("888888888888\n");rn setstatus(1,1,1,1,1);rn printf("move cursor,press any key\n");rn getch();rnrn for (i=1;i<13;i++)rn rn cursorhome();rn setcursor(i);rn delay(1500);rn cleardisplay(); rn rn printf("press any to exit!"); rn getch();rn 论坛

没有更多推荐了,返回首页