Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Python 3 in pfsense

    Scheduled Pinned Locked Moved pfSense Packages
    28 Posts 9 Posters 12.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      CouldntMakeUpOne @Kalle13
      last edited by

      @kalle13 Sorry, what do you mean the http path of the repo. Any guide I can follow. I'm fairly new to this.

      1 Reply Last reply Reply Quote 0
      • Kalle13K
        Kalle13
        last edited by

        Read this for installation:

        https://docs.netgate.com/pfsense/en/latest/packages/installing-freebsd-packages.html

        and use these repos:
        http://pkg.freebsd.org/freebsd:11:x86:64/latest/All/

        "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

        • Kinderzimmer Productions
        GrimsonG 1 Reply Last reply Reply Quote 0
        • GrimsonG
          Grimson Banned @Kalle13
          last edited by

          @kalle13 said in Python 3 in pfsense:

          and use these repos:
          http://pkg.freebsd.org/freebsd:11:x86:64/latest/All/

          Just don't come crying when the next pfSense update fails.

          Kalle13K 1 Reply Last reply Reply Quote 0
          • Kalle13K
            Kalle13 @Grimson
            last edited by

            @grimson Really? I did not know that. Is this for sure when I am installing other repos?

            "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

            • Kinderzimmer Productions
            GrimsonG 1 Reply Last reply Reply Quote 0
            • GrimsonG
              Grimson Banned @Kalle13
              last edited by

              @kalle13 said in Python 3 in pfsense:

              @grimson Really? I did not know that. Is this for sure when I am installing other repos?

              It has happened in the past already.

              Kalle13K 1 Reply Last reply Reply Quote 0
              • jimpJ
                jimp Rebel Alliance Developer Netgate
                last edited by

                He's right. Do not be surprised when that causes problems. Do not do that on a production system you care about.

                Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                Need help fast? Netgate Global Support!

                Do not Chat/PM for help!

                1 Reply Last reply Reply Quote 0
                • GertjanG
                  Gertjan
                  last edited by

                  On the other hand : if one is comfortable with installing from the standard FreeBSD repository, upgrading by re installing "from scratch" will be no issue at all.

                  No "help me" PM's please. Use the forum, the community will thank you.
                  Edit : and where are the logs ??

                  1 Reply Last reply Reply Quote 0
                  • Kalle13K
                    Kalle13 @Grimson
                    last edited by

                    @grimson Ok, thanks for your advice. I keep that in mind when the next upodate arrives. What can I do if the update fails?

                    "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

                    • Kinderzimmer Productions
                    KOMK 1 Reply Last reply Reply Quote 0
                    • KOMK
                      KOM @Kalle13
                      last edited by

                      @kalle13 Reinstall fresh, restore your xml config and then re-add the Python3 package. Plus, the update may not fail, but it may blow away your Python3 package and cause the things you need it for to break.

                      Kalle13K 1 Reply Last reply Reply Quote 0
                      • Kalle13K
                        Kalle13 @KOM
                        last edited by

                        @kom Thanks for your advice!

                        "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

                        • Kinderzimmer Productions
                        1 Reply Last reply Reply Quote 0
                        • C
                          CouldntMakeUpOne
                          last edited by

                          Hi everyone, sorry for being this thread up again but what about python 2 in the meantime? I saw that there is already python 2 inside pfsense using "pkg info" but I am not able to run python commands. Do I need to do some sort of extraction?

                          jimpJ 1 Reply Last reply Reply Quote 0
                          • jimpJ
                            jimp Rebel Alliance Developer Netgate @CouldntMakeUpOne
                            last edited by

                            @couldntmakeupone said in Python 3 in pfsense:

                            Hi everyone, sorry for being this thread up again but what about python 2 in the meantime? I saw that there is already python 2 inside pfsense using "pkg info" but I am not able to run python commands. Do I need to do some sort of extraction?

                            Python 2.7 is there and works fine, it just isn't in the python command, but python2.7. If you must have it available when typing python then make an alias or symlink.

                            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                            Need help fast? Netgate Global Support!

                            Do not Chat/PM for help!

                            1 Reply Last reply Reply Quote 0
                            • C
                              CouldntMakeUpOne
                              last edited by

                              @jimp said in Python 3 in pfsense:

                              symlink.

                              So, can I just run python 2.7 programs in pfsense by using ./python.py?

                              1 Reply Last reply Reply Quote 0
                              • jimpJ
                                jimp Rebel Alliance Developer Netgate
                                last edited by

                                If you edit the shabang line to use the correct path to the binary, yes. If you have more questions, please start your own thread as it isn't related to this topic.

                                Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                Need help fast? Netgate Global Support!

                                Do not Chat/PM for help!

                                1 Reply Last reply Reply Quote 0
                                • jwsiJ
                                  jwsi
                                  last edited by

                                  To solve this I have created a public repo on GitHub with precompiled Python 3 binaries for specific releases of pfSense:

                                  pfSense Python 3

                                  If you follow the instructions, it's a very straightforward process and will allow you to choose whatever Python 3 version works for you :)

                                  G 1 Reply Last reply Reply Quote 1
                                  • G
                                    guardian Rebel Alliance @jwsi
                                    last edited by

                                    @jwsi Thanks very much for this. I was wondering how to approach this issue.

                                    I was wondering if I could simplify the installation procedure... I just want python3.6 for amd64, can I just download from github to /root on my pfSense box?

                                    curl -L -o Python3.6_pfSense2.4.4-RELEASE-p3_amd64.txz  https://github.com/ultrahorizon/pfSense-Python3/raw/master/2.4.4-RELEASE-p3/amd64/3.6.txz
                                    pkg add Python3.6_pfSense2.4.4-RELEASE-p3_amd64.txz
                                    

                                    I'm assuming that it does not matter that I renamed the file Python3.6_pfSense2.4.4-RELEASE-p3_amd64.txz as long as I use the same file name in the pkg add command.
                                    (Note the -L option since github redirects the URL obtained by saving the link on the download button.)

                                    I'm hoping this is OK so I don't need to clone the whole repo and install git.

                                    If you find my post useful, please give it a thumbs up!
                                    pfSense 2.7.2-RELEASE

                                    1 Reply Last reply Reply Quote 0
                                    • jwsiJ
                                      jwsi
                                      last edited by

                                      Hi @guardian,

                                      So this is actually documented in the "Easy Installation" section of the README.

                                      For Python 3.6 on amd64 you can simply execute:

                                      cd /tmp
                                      fetch https://github.com/ultrahorizon/pfSense-Python3/raw/master/2.4.4-RELEASE-p3/amd64/3.6.txz
                                      pkg add 3.6.txz
                                      

                                      Then the file will be removed from the /tmp folder in due course. I would probably advise downloading to the tmp folder or deleting the .txz file after install because there's no need to keep it around.

                                      Let me know if that works for you ☺

                                      G 1 Reply Last reply Reply Quote 2
                                      • G
                                        guardian Rebel Alliance @jwsi
                                        last edited by

                                        @jwsi Thanks... that does the fetch just fine... still working a few things out before I run it.

                                        I assume this leaves python2.7 Installed and I run the new python as /usr/local/bin/python3.6 correct?

                                        Does install include pip? If not, how do I install it (I need a couple of extra packages)

                                        What command do I use to run pip for python3.6 instead of python2.7?

                                        P.S.: For the benefit of anyone running this that doesn't know their way around the command line, they can just run rm 3.6.txz after the install is done to get rid of the file.

                                        If you find my post useful, please give it a thumbs up!
                                        pfSense 2.7.2-RELEASE

                                        1 Reply Last reply Reply Quote 0
                                        • jwsiJ
                                          jwsi
                                          last edited by

                                          Great to hear that it works @guardian.

                                          If you reload the pfSense shell after installing (type exit then hit option 8 again) you will be able to use Python 3.6 by typing python3.6 in the command line. However, the full path you quoted is indeed correct too.

                                          With regards to pip, this is already bundled as a module. To install simply execute:

                                          python3.6 -m ensurepip

                                          Then Python3's pip is available under the command pip3 (another shell reload will likely be required here...). It's also advised to upgrade pip to the latest version too. Therefore, after installation execute:

                                          pip3 install --upgrade pip

                                          G 1 Reply Last reply Reply Quote 0
                                          • G
                                            guardian Rebel Alliance @jwsi
                                            last edited by

                                            @jwsi said in Python 3 in pfsense:

                                            Great to hear that it works @guardian.

                                            If you reload the pfSense shell after installing (type exit then hit option 8 again) you will be able to use Python 3.6 by typing python3.6 in the command line. However, the full path you quoted is indeed correct too.

                                            With regards to pip, this is already bundled as a module. To install simply execute:

                                            python3.6 -m ensurepip

                                            Then Python3's pip is available under the command pip3 (another shell reload will likely be required here...). It's also advised to upgrade pip to the latest version too. Therefore, after installation execute:

                                            pip3 install --upgrade pip

                                            @jwsi thank you very much. I've just used default python2.7 on all my systems till now (don't do much dev-just the odd admin/helper script), so now I have to learn how to do things properly so that really helps. I will wait till I upgrade from p2 -> p3 before running, but I'll report back to confirm that everything works OK.

                                            If you find my post useful, please give it a thumbs up!
                                            pfSense 2.7.2-RELEASE

                                            jwsiJ 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.