Navigation

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

    Python 3 in pfsense

    pfSense Packages
    9
    28
    6584
    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 last edited by

      Hey, installed pfsense version 2.4.4. Is there a way to install python 3 in it so that I can run a script? I saw from pkg info that 2.7 is in it, do I have to unpack it? I would much prefer python 3 though.

      1 Reply Last reply Reply Quote 0
      • BBcan177
        BBcan177 Moderator last edited by

        https://redmine.pfsense.org/issues/9360

        "Experience is something you don't get until just after you need it."

        Website: http://pfBlockerNG.com
        Twitter: @BBcan177  #pfBlockerNG
        Reddit: https://www.reddit.com/r/pfBlockerNG/new/

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

          Reading that, am I right to assume that python3 will only be implemented by 2020?
          Is there any way I can go about running a python3 script now?

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

            We will have pfSense 2.5.0 snapshots available soon with Python 3.6, which you can use for testing then. No ETA, but very soon. We have only a few minor blockers to solve internally before they are ready for public testing.

            [2.5.0-DEVELOPMENT][root@jack]/root: pkg info -x python
            python36-3.6.7
            [2.5.0-DEVELOPMENT][root@jack]/root: python3.6 --version
            Python 3.6.7
            

            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

              Oh, that's great.
              Few questions though, sorry fairly new to the forum.
              1)Will it be within the month?
              2)Is there any way I can sign up to receive a notification when it is released?
              3)Will it be available to download like all the versions via https://www.pfsense.org/download/ ?

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

                1. The snapshots should be available soon, but we can't given an ETA. I'd expect them well before the end of the month, but no guarantees. The release will not be for some time yet after that, a few months, most likely.

                2. I'm not sure where we will announce them, probably here on the forum and reddit at least. There might be a blog post, but probably not an announcement e-mail. It will probably be hard to miss when it happens.

                3. Not from that URL, since it won't be a release for quite some time. Development snapshots are on https://snapshots.pfsense.org/

                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
                • Kalle13
                  Kalle13 last edited by

                  You can install python 3 from the from the official ports of FreeBSD 11. I did it several days ago.
                  For the installation you need the http path of the repo to install it. It is because pfsense has not all repos but only a tiny bit.

                  Kalle

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

                  • Kinderzimmer Productions
                  C 1 Reply Last reply Reply Quote 0
                  • 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
                    • Kalle13
                      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
                      Grimson 1 Reply Last reply Reply Quote 0
                      • Grimson
                        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.

                        Kalle13 1 Reply Last reply Reply Quote 0
                        • Kalle13
                          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
                          Grimson 1 Reply Last reply Reply Quote 0
                          • Grimson
                            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.

                            Kalle13 1 Reply Last reply Reply Quote 0
                            • jimp
                              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
                              • Gertjan
                                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.

                                1 Reply Last reply Reply Quote 0
                                • Kalle13
                                  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
                                  KOM 1 Reply Last reply Reply Quote 0
                                  • KOM
                                    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.

                                    Kalle13 1 Reply Last reply Reply Quote 0
                                    • Kalle13
                                      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?

                                        jimp 1 Reply Last reply Reply Quote 0
                                        • jimp
                                          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
                                            • jimp
                                              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
                                              • jwsi
                                                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 @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.5.2-RELEASE-CE

                                                  1 Reply Last reply Reply Quote 0
                                                  • jwsi
                                                    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 @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.5.2-RELEASE-CE

                                                      1 Reply Last reply Reply Quote 0
                                                      • jwsi
                                                        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 @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.5.2-RELEASE-CE

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

                                                            @guardian great! Look forward to hearing how you get on ☺

                                                            1 Reply Last reply Reply Quote 1
                                                            • First post
                                                              Last post