Jump to content
  • Advertisement
Sign in to follow this  

How to import a custom module?

This topic is 1268 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


 i have a custom module, I want to put it in the directory to import it. What should I do?


i got this error :

importError: No module named 'pyperclip' 



?i use Linux Debian


i downloaded the module from :





what should i do to import it  sad.png


i tried many commands in Konsole sad.png


like sudo apt-get install python3-setuptools etc....








Edited by koka282

Share this post

Link to post
Share on other sites

You are running Python - IDLE(Shell) from a location outside from where your script is located.


Option 1). Open the directory where the pyperclip.py file is located. Then right click on it and select edit with Python - IDLE. This will change IDLEs current working directory.

Option 2). Open up Terminal and CD to the location of pyperclip.py then run the command: python pyperclip.py.


Now you'll be able to import pyperclip.py with:

import pyperclip

Share this post

Link to post
Share on other sites

Install pip and pip install pyperclip




cd pyperclip

python setup.py install


Make sure you're running terminal as su


Why pip? Pip is a light tool that makes it really easy to install future packages you just go pip install name-of-the-package so give it a try, most people use it. There's other tools like it I believe if you want to search for it.


For other packages it's similar.


Importing should work after that

Edited by olaolaola

Share this post

Link to post
Share on other sites

Python does not know where to find the module you're trying to load.  It normally only looks in the configured system installation path, and that depends on a number of factors (given you're running KDE my guess is you're on Linux, so I'll point out it depends on the Python version and the distro you're running).


To add additional search paths for importing modules when running Python, use the PYTHONPATH environment variable.  In your Konsole shell, try


  PYTHONPATH=~/pythonpractice python


This is assuming you have a file called ~/pythonpractice/pyperclip/__init__.py (which is the file Python will be looking for when you import pyperclip).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!