blob: c8d8a1c28a92d3481d2494169743222489040a1c [file] [log] [blame]
"use strict";(self.webpackChunkwebsite_next=self.webpackChunkwebsite_next||[]).push([[70619],{15680:(e,t,n)=>{n.d(t,{xA:()=>c,yg:()=>m});var r=n(96540);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var p=r.createContext({}),s=function(e){var t=r.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},c=function(e){var t=s(e.components);return r.createElement(p.Provider,{value:t},e.children)},u="mdxType",y={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},g=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,l=e.originalType,p=e.parentName,c=o(e,["components","mdxType","originalType","parentName"]),u=s(n),g=a,m=u["".concat(p,".").concat(g)]||u[g]||y[g]||l;return n?r.createElement(m,i(i({ref:t},c),{},{components:n})):r.createElement(m,i({ref:t},c))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var l=n.length,i=new Array(l);i[0]=g;var o={};for(var p in t)hasOwnProperty.call(t,p)&&(o[p]=t[p]);o.originalType=e,o[u]="string"==typeof e?e:a,i[1]=o;for(var s=2;s<l;s++)i[s]=n[s];return r.createElement.apply(null,i)}return r.createElement.apply(null,n)}g.displayName="MDXCreateElement"},2725:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>i,default:()=>y,frontMatter:()=>l,metadata:()=>o,toc:()=>s});var r=n(58168),a=(n(96540),n(15680));const l={id:"client-libraries-python-setup",title:"Set up Python client",sidebar_label:"Set up"},i=void 0,o={unversionedId:"client-libraries-python-setup",id:"version-3.0.x/client-libraries-python-setup",title:"Set up Python client",description:"Install Python client library",source:"@site/versioned_docs/version-3.0.x/client-libraries-python-setup.md",sourceDirName:".",slug:"/client-libraries-python-setup",permalink:"/docs/3.0.x/client-libraries-python-setup",draft:!1,editUrl:"https://github.com/apache/pulsar-site/edit/main/versioned_docs/version-3.0.x/client-libraries-python-setup.md",tags:[],version:"3.0.x",frontMatter:{id:"client-libraries-python-setup",title:"Set up Python client",sidebar_label:"Set up"},sidebar:"docsSidebar",previous:{title:"Python client",permalink:"/docs/3.0.x/client-libraries-python"},next:{title:"Initialize",permalink:"/docs/3.0.x/client-libraries-python-initialize"}},p={},s=[{value:"Install Python client library",id:"install-python-client-library",level:2},{value:"Connect to Pulsar cluster",id:"connect-to-pulsar-cluster",level:2}],c={toc:s},u="wrapper";function y(e){let{components:t,...n}=e;return(0,a.yg)(u,(0,r.A)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.yg)("h2",{id:"install-python-client-library"},"Install Python client library"),(0,a.yg)("p",null,"Use ",(0,a.yg)("a",{parentName:"p",href:"https://pip.pypa.io/"},"pip")," to install the latest version:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"pip install 'pulsar-client==3.5.0'\n")),(0,a.yg)("p",null,"You can install optional components alongside the client library:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"# avro serialization\npip install 'pulsar-client[avro]==3.5.0'\n\n# functions runtime\npip install 'pulsar-client[functions]==3.5.0'\n\n# all optional components\npip install 'pulsar-client[all]==3.5.0'\n")),(0,a.yg)("p",null,"Installation via PyPi is available for the following Python versions:"),(0,a.yg)("table",null,(0,a.yg)("thead",{parentName:"table"},(0,a.yg)("tr",{parentName:"thead"},(0,a.yg)("th",{parentName:"tr",align:"left"},"Platform"),(0,a.yg)("th",{parentName:"tr",align:"left"},"Supported Python versions"))),(0,a.yg)("tbody",{parentName:"table"},(0,a.yg)("tr",{parentName:"tbody"},(0,a.yg)("td",{parentName:"tr",align:"left"},"macOS (>= 11.0)"),(0,a.yg)("td",{parentName:"tr",align:"left"},"3.7, 3.8, 3.9 and 3.10")),(0,a.yg)("tr",{parentName:"tbody"},(0,a.yg)("td",{parentName:"tr",align:"left"},"Linux (including Alpine Linux)"),(0,a.yg)("td",{parentName:"tr",align:"left"},"3.7, 3.8, 3.9 and 3.10")))),(0,a.yg)("h2",{id:"connect-to-pulsar-cluster"},"Connect to Pulsar cluster"),(0,a.yg)("p",null,"To connect to Pulsar using client libraries, you need to specify a ",(0,a.yg)("a",{parentName:"p",href:"/docs/3.0.x/developing-binary-protocol"},"Pulsar protocol")," URL."),(0,a.yg)("p",null,"You can assign Pulsar protocol URLs to specific clusters and use the ",(0,a.yg)("inlineCode",{parentName:"p"},"pulsar")," scheme. The following is an example of ",(0,a.yg)("inlineCode",{parentName:"p"},"localhost")," with the default port ",(0,a.yg)("inlineCode",{parentName:"p"},"6650"),":"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-http"},"pulsar://localhost:6650\n")),(0,a.yg)("p",null,"If you have multiple brokers, separate ",(0,a.yg)("inlineCode",{parentName:"p"},"IP:port")," by commas:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-http"},"pulsar://localhost:6550,localhost:6651,localhost:6652\n")),(0,a.yg)("p",null,"If you use ",(0,a.yg)("a",{parentName:"p",href:"/docs/3.0.x/security-tls-authentication"},"mTLS")," authentication, add ",(0,a.yg)("inlineCode",{parentName:"p"},"+ssl")," in the scheme:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-http"},"pulsar+ssl://pulsar.us-west.example.com:6651\n")))}y.isMDXComponent=!0}}]);