# Import InfluxDBClient fails in python code

**URL:** <https://community.influxdata.com/t/import-influxdbclient-fails-in-python-code/14239>\
**Category:** Client SDKs\
**Tags:** python\
**Created:** [May 8, 2020, 9:19am UTC](https://community.influxdata.com/t/import-influxdbclient-fails-in-python-code/14239 "2020-05-08T09:19:46Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![svet](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/svet/32/7092_2.png) [@svet](https://community.influxdata.com/u/svet)\
**Post date:** [May 12, 2020, 6:38am UTC](https://community.influxdata.com/t/import-influxdbclient-fails-in-python-code/14239/8 "2020-05-12T06:38:01Z")

</div>

Ok, I think I see the problem - hinted at by @Anaisdg’s [post](https://community.influxdata.com/t/correct-version-for-raspberry-pi-models/14285/3) in the discussion that somehow got “forked” into the other thread.

**Option 1: Legacy client**  
To use the legacy (Influx 1.x focused) client, you need to install with

```auto
pip3 install influxdb

```

to get this package: [influxdb · PyPI](https://pypi.org/project/influxdb/), and then when you run Python you should be able to import it with

```auto
from influxdb import InfluxDBClient

```

as you’ve been attempting so far.

**Option 2: New client**  
If you’d like to use the new (Influx 2.0 focused) client, you need to install with

```auto
pip3 install influxdb-client

```

to get this package: [influxdb-client · PyPI](https://pypi.org/project/influxdb-client/), and then when you run Python you should be able to import it with

```auto
import influxdb_client

```

In short, I think what happened is that you’ve installed the new Python package, but are trying to import the legacy one (which isn’t installed). If you’re running an Influx 1.8 server (as I gather from your other thread), then you should be able to use either package. It’s mostly down to whether you’d like to write your queries using Flux - in which case use the new client - or InfluxQL - in which case you should use the legacy client. Flux is very powerful, but if you’re looking to do something reasonably simple then InfluxQL will probably be fine.

---

_[View the full topic](https://community.influxdata.com/t/import-influxdbclient-fails-in-python-code/14239)._
