0

I'm trying to import a module that has a dash in the module name. Whenever I try this, I get a syntax error. Can I get some help?

I've tried reinstalling the module with pip3 I've also tried using the underscore symbol instead of the dash

import instabot-py

I expect the code to just run but the error 'SyntaxError: invalid syntax' pops up.

milanbalazs
  • 4,811
  • 4
  • 23
  • 45
hifromdev
  • 262
  • 3
  • 10

1 Answers1

1

First, it doesn't look like Instabot.py is actually designed to be imported. I haven't found anything in its docs suggesting manual imports are a supported name.

The name on PyPI has a hyphen in it, but that's not the name you have to import (assuming importing it actually works). The name on PyPI can be completely different from the name you have to import. In this case, the name you import is instabot_py, with an underscore.

In general, people who know what they're doing don't make modules with hyphens in the name, because such names are incompatible with the import statement. This program's author picked an underscore instead, a common choice.

user2357112
  • 260,549
  • 28
  • 431
  • 505