Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'minio' #8

Closed
Netology-DS opened this issue Aug 19, 2021 · 2 comments
Closed

No module named 'minio' #8

Netology-DS opened this issue Aug 19, 2021 · 2 comments

Comments

@Netology-DS
Copy link

Netology-DS commented Aug 19, 2021

Hi.
How i try bash ./run_create_bucket.sh after docker-compose up -d, i see trourble

Traceback (most recent call last):
File "./create_bucket.py", line 3, in
from minio import Minio
ModuleNotFoundError: No module named 'minio'

I try another minio version, lates, 6, 7 - trouble repeat.

My ENV
Python 3.7.3
pip 21.2.4 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
CentOS Linux release 7.9.2009 (Core)
minio 7.0.0
Docker version 18.06.0-ce, build 0ffa825
docker-compose version 1.29.2, build 5becea4c

@Toumash
Copy link
Owner

Toumash commented Aug 19, 2021

This docker container executing minio install and import is working just fine. Are you sure you are not using some virtualenv, and that the shell and directory has the minio installed?

Actual problem

Your pip "pip 21.2.4 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)" is different from the python you are using. Make sure you are using the same pip/python combination

The easiest solution ✨

just run

import subprocess
import sys

def install(package):
    subprocess.check_call([sys.executable, "-m", "pip", "install", package])

as stated in:
https://stackoverflow.com/a/50255019/3711660

but really, try to uninstall other versions of python to not confuse yourself

Proof that this is working

docker run --rm -it --name minio_test python:3.7-alpine ash -c "pip install minio==7;pip show minio; echo \"from minio import Minio; print('Hello, world ')\" >> ab.py; python ./ab.py"

Useful commands:

pip show minio # check which minio version you are using
pip install minio # install minio

You can also try to run the script directly without using run_create_bucket.sh by using

pip3 install Minio
python3 ./create_bucket.py
My output
$  docker run --rm -it --name minio_test python:3.7-alpine ash -c "pip install minio==7;pip show minio; echo \"from minio import Minio; print('Hello, world ')\" >> ab.py; python ./ab.py"
Collecting minio==7
  Downloading minio-7.0.0-py3-none-any.whl (72 kB)
     |████████████████████████████████| 72 kB 662 kB/s
Collecting certifi
  Downloading certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
     |████████████████████████████████| 145 kB 7.5 MB/s
Collecting urllib3
  Downloading urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 7.4 MB/s
Collecting configparser
  Downloading configparser-5.0.2-py3-none-any.whl (19 kB)
Installing collected packages: urllib3, configparser, certifi, minio
Successfully installed certifi-2021.5.30 configparser-5.0.2 minio-7.0.0 urllib3-1.26.6
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Name: minio
Version: 7.0.0
Summary: MinIO Python SDK for Amazon S3 Compatible Cloud Storage
Home-page: https://github.com/minio/minio-py
Author: MinIO, Inc.
Author-email: dev@min.io
License: Apache License 2.0
Location: /usr/local/lib/python3.7/site-packages
Requires: urllib3, configparser, certifi
Required-by:
Hello, world

@Toumash
Copy link
Owner

Toumash commented Oct 14, 2021

closing since the issue was resolved

@Toumash Toumash closed this as completed Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants