Ask coding questions

← Back to all posts
How can I import this module?
HayIsForHorses

I want to import a module without using pip install, but here's the problem..
import restricted-input
The name of the package includes a hyphen AND a syntax, so the output throws this error:

How can I do this?

Answered by MrVoo [earned 5 cycles]
View Answer
Comments
hotnewtop
MrVoo

The actual module name probably doesn't have a dash, try investigating further

HayIsForHorses
HayIsForHorses

@HayIsForHorses
github = https://github.com/FuturisticGoo/restricted_input
i also tried importing it as restricted_input but that just says that it isn't a valid package.

MrVoo

@HayIsForHorses What error did it give when you used an underscore? If it said something along the lines of unknown package, add it through he packages tab (looks like a cube)

HayIsForHorses

@MrVoo Also found this in the main.py file on the github.

so then I did:

but then:

:/

HayIsForHorses

@MrVoo I can also just paste the package code into my code... but that would be unhealthy imo

HayIsForHorses

@MrVoo I get that..... but wouldn't that not install the package for others?

CosmicBear

@HayIsForHorses try pip3 install restricted_input

HayIsForHorses

@CosmicBear Yeah, I already know how to do that. But, I am afraid it won't install for the others when they run the script.

CosmicBear

@HayIsForHorses have the program run the command at the start of the script.

HayIsForHorses

@CosmicBear how would i do that

MrVoo

@HayIsForHorses The packages tab adds the package for other people too.

HayIsForHorses

@MrVoo Thank you!

CosmicBear

Try this

@HayIsForHorses

MrVoo

@CosmicBear Or just `py
import os
os.system('pip install restricted_input')