Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing py Files
#1
Hi
I have a bunch of .py files sitting in my command line directory path and I wish to install them to Python3. I have tried 'sudo apt install filename.py' and sudo apt-get install python-filename ect but they don't recognize the files. Any solutions please?

Regards
dave
Reply
#2
You could do the following
  1. Create a directory for these Python files, for example /home/myname/pymods
  2. Find the per user site-packages directory. For this, start python and run
    >>> import site
    >>> site.getusersitepackages()
    On the computer where I'm writing this, it prints '/home/eric/.local/lib/python3.8/site-packages'. This is the path to the directory
  3. In this directory, create a file named usercustomize.py (if it does not already exist). In this file add code
    # usercustomize.py
    import site
    site.addsitedir('/home/myname/pymods')
You can now import these python modules.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020