简体   繁体   中英

Python cannot find module in the same folder

I have spotipy installed on python3, and when I run it, it calls the __init__.py file, but then that file attempts to import from client, and it says that client can not be found, although client.py is in the same folder as __init__.py .

I'm wondering if the issue lies in the fact that I have multiple versions of python installed?

EDIT: The working directory only has the file I'm running, which as of now simply says "import spotipy". Also, I checked, and it seems like the __init__.py file is unable to import anything else in the folder.

As James said, you need to place empty file __init__.py in your folder. Then Python will think of this folder as of a package and you will be able to do your imports.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM