Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
fuf
Sep 12, 2004

haha
lol PyCharm won't even let me create a virtual environment for 2.6 because it's so old :(

fuf fucked around with this message at 12:30 on Mar 4, 2020

Adbot
ADBOT LOVES YOU

NinpoEspiritoSanto
Oct 22, 2013




I forgot about epel. There's also ius repo which has a lot of py3 builds for CentOS

QuarkJets
Sep 8, 2008

Wait, how'd you get PyCharm installed?

e: Oh probably on a separate development machine, nevermind

fuf
Sep 12, 2004

haha

QuarkJets posted:

Wait, how'd you get PyCharm installed?

e: Oh probably on a separate development machine, nevermind

yeah so far I'm just having fun testing all this stuff on my local machine

I've still gotta convince the powers that be to install the pysftp package on the TEST server (let alone the LIVE server) before I can test it properly

NinpoEspiritoSanto
Oct 22, 2013




fuf posted:

yeah so far I'm just having fun testing all this stuff on my local machine

I've still gotta convince the powers that be to install the pysftp package on the TEST server (let alone the LIVE server) before I can test it properly

I work both sides of the dev/sysad fence and there's no excuse for it to be this difficult for you

fuf
Sep 12, 2004

haha

Bundy posted:

I work both sides of the dev/sysad fence and there's no excuse for it to be this difficult for you

It can be frustrating but I'm getting used to it. It's a big public institution (a university) so they are just very risk averse, with a lot of well-intentioned but only half-implemented "change management" procedures. I'm confident I'll get the things I need eventually, it's just a slow process!

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

fuf posted:

I'm confident I'll get the things I need eventually, it's just a slow process!

:allears:

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:
I also work for a university.

We update to Debian new stable version at the .1 release. Your software runs on Debian stable. If it doesn't, well, you better work on getting that fixed because once oldstable runs out the VM gets killed.

It's actually pretty nice. We have a very clear two year upgrade rhythm. It's always a little behind the state of the art, but not that far. Sometimes a bit of Django stuff needs updating but it's all easy to manage.

It is my experience that orgs that fall behind too much never manage the jump to the present ever again. Once you are too far behind the accumulated mass of changes becomes too much for an upgrade and people give up.

NinpoEspiritoSanto
Oct 22, 2013




Antigravitas posted:

It is my experience that orgs that fall behind too much never manage the jump to the present ever again. Once you are too far behind the accumulated mass of changes becomes too much for an upgrade and people give up.

Same and it ultimately defeats the whole "stability through precaution" approach as any software you're running ends up stuck with any security holes it's got. For example a place I am familiar with is currently still stuck running on PHP 5.5 due to poor planning/not moving off CentOS6 and little will to upgrade previously and are finding it very painful as needing to be secure and compliant is eroding at that "it's too hard" excuse.

It's 2020, even if you're still colo-ing there's enough tools available to make at least following CentOS/Debian Stable/Ubuntu LTS largely trivial.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I feel like I need to unsubscribe from this thread until the talk about using Python 2.6 passes or else my corporate IT web monitor will detect posts about using it and keep us on Python 2 forever.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Package your python 3.8 scripts with PyInstaller or the like and then run them on whatever system you like!

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:
Of course, using debootstrap to create a Debian Buster installation and shipping it whole is the real pro move. No need for container orchestration, just chroot!

Dominoes
Sep 20, 2007

Thermopyle posted:

Package your python 3.8 scripts with PyInstaller or the like and then run them on whatever system you like!
Yeah!

Expecting a specific Py version/dep setup's awk, even though it's common, or sometimes mitigated by venvs.

NinpoEspiritoSanto
Oct 22, 2013




*looks wistfully at Go binary distribution*

Dominoes
Sep 20, 2007

I hate when I'm trying to install software, and it turns out to be unwrapped Python. Often doesn't work or is a pain to get working.

Dudes who are struggling with old Py versions at work: What's the stumbling block? (eg: Your code for a work proj has to work with a larger old Py codebase? Your work won't let you install anything? Installing a normal system-install of Py3.8 would conflict with a diff install?)

Has anyone here tried Nuitka or PyOxidizer? They're supposed to help with packaging Python code as executables.

Dominoes fucked around with this message at 01:35 on Mar 5, 2020

QuarkJets
Sep 8, 2008

Dominoes posted:

I hate when I'm trying to install software, and it turns out to be unwrapped Python. Often doesn't work or is a pain to get working.

Dudes who are struggling with old Py versions at work: What's the stumbling block? (eg: Your code for a work proj has to work with a larger old Py codebase? Your work won't let you install anything? Installing a normal system-install of Py3.8 would conflict with a diff install?)

9/10 times it's going to be a culture that's using configuration management as an excuse to delay OS upgrades. That's what keeps my org still running RHEL 6 systems long after other groups in the same org have moved onto 7 and 8. So since configuration is the concern you're likely stuck with whatever versions of Python are available in the now very old but still official OS repos

Dominoes
Sep 20, 2007

Is Py 3.8 incompatible with RH6? Ie why can't you install it or load a standalone portable Py?

What about loading binaries that include the code and interpreter?


Maybe-related issue where a dude could only use the pypi Version of a py proj manager since he wasn't allowed to load the rpm. (The pypi v was built for newer Linux so didn't work)

Evidently even binaries can have dep issues with older linux distros, but it's easy enough to compile on Centos in addition to new Oss

Dominoes fucked around with this message at 15:17 on Mar 5, 2020

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I don't know about installing a package to get such a new interpreter. I have built from source on some pretty old OSes and been fine. The hard part was getting some of the auxiliary stuff to get included like readline. Installing it into a system path comes at the risk of blowing up distribution-specific Python scripts. If the machine is otherwise strictly secured despite running ancient, exploitable software, the build may need permissions to do what you want. I have not had good luck with that politically.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I was only partly kidding about using PyInstaller or equivalent. I've done that several times for distributing a script to systems on a network because of overly-cautious system administrators.

Conda and pyenv are both potential solutions as well since they just install in the user directory and might not require compiling something with build tools not available on the target distro.

Dominoes
Sep 20, 2007

I can't remember what it is, but there's a flag you can pass to the compiler that lets you build CPython into its own folder; as you implied, the default settings will try to install it to the system. Overall it's a 2 or 3 liner to build, using the source code from the Python website. Might be worth trying.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
code:
./configure --enable-optimizations --prefix=/path/to/install
make -j4         (I had two cores)
make altinstall
You probably want to see the configure output to see what it's not building and if you care. I think you get a different thing between building 2.7 and 3.X. In my case, I knew I'd need readline and possible _curses so I had to make sure those source packages were available. The 2.7 output included a lot of deprecated stuff I could ignore like dl and imageop.

I don't think the -j4 flag really helped any on that old of an OS and machine, but it's habit. The build tools were the ones from the OS package and were also old like everything else.

Thermopyle posted:

I was only partly kidding about using PyInstaller or equivalent. I've done that several times for distributing a script to systems on a network because of overly-cautious system administrators.

Conda and pyenv are both potential solutions as well since they just install in the user directory and might not require compiling something with build tools not available on the target distro.

Nobody's acknowledging Thermopyle, but this is fine advice.

Dominoes
Sep 20, 2007

Awesome

QuarkJets
Sep 8, 2008

Dominoes posted:

Is Py 3.8 incompatible with RH6? Ie why can't you install it or load a standalone portable Py?

What about loading binaries that include the code and interpreter?

You can, and that was the advice initially given (e.g. Use Anaconda), but OP was concerned about "rocking the boat". I take that as meaning that it's an issue with IT policies; OP can bring in scripts that run with an official centos6 interpreter but probably can't provide new binaries

Dominoes
Sep 20, 2007

Shower thought: You can wrap arbitrary executables in Python wheels. Ie make an empty package, and put the executable in the wheel file under data/scripts, and some metadata in dist-info. You can then put this on Pypi, and users can install it with pip, then have it available from the CLI etc.


I'd bet you could put a whole Python install inside a wheel. Pythonception. And it could be installed on your geriatric locked-down enterprise Linux.

edit: The naive approach isn't working. I think the inner python's having trouble finding its libraries.

Dominoes fucked around with this message at 20:45 on Mar 6, 2020

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Dominoes posted:

Shower thought: You can wrap arbitrary executables in Python wheels. Ie make an empty package, and put the executable in the wheel file under data/scripts, and some metadata in dist-info. You can then put this on Pypi, and users can install it with pip, then have it available from the CLI etc.


I'd bet you could put a whole Python install inside a wheel. Pythonception. And it could be installed on your geriatric locked-down enterprise Linux.

edit: The naive approach isn't working. I think the inner python's having trouble finding its libraries.

I think the interpreter they're talking doesn't even know what pip is, or if it does, it doesn't know what wheels are, and installing wheel is an IT party foul. Actually, I think I had a case where pip was too old to install wheel.

I haven't had to deal with an environment like that being locked down by IT, but rather clones of test OSes where I had to be able to easily share the process. Building from source would not have been considered an easy thing in the situation. Running get-pip was even too much. :suicide101:

Dominoes
Sep 20, 2007

Ick. I was able to run arbitrary code at work by making a webapp. To make things better, I got computers funded by a side-channel, and they run on non-official wifi we have. So comm has no control and the computers run fast since there's no beurocratic shitware slowing them down. I don't think comm would even care since neither the comps nor server touch their network.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I'm convinced the most common way we use technology is to try to solve political problems.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Thermopyle posted:

Package your python 3.8 scripts with PyInstaller or the like and then run them on whatever system you like!

PyInstaller gets nuked as a virus by most antivirus softwares.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

CarForumPoster posted:

PyInstaller gets nuked as a virus by most antivirus softwares.

I've found this to be very inconsistent.

Tortilla Maker
Dec 13, 2005
Un Desmadre A Toda Madre
Newbie question:

I'm currently getting the following error:

quote:

NameError: name 'df' is not defined

code:
def generate_df():
    df = pd.DataFrame({'user': ['bob', 'jane'],
                 'income': [20000, 45000]})
    return df

StackOverflow generally emphasized including 'return' but it doesnt seem to help. Other posts suggested placing this in a class but no luck for me either.

Appreciate any suggestions!

M. Night Skymall
Mar 22, 2012

Tortilla Maker posted:

Newbie question:

I'm currently getting the following error:


code:
def generate_df():
    df = pd.DataFrame({'user': ['bob', 'jane'],
                 'income': [20000, 45000]})
    return df
StackOverflow generally emphasized including 'return' but it doesnt seem to help. Other posts suggested placing this in a class but no luck for me either.

Appreciate any suggestions!

Is that the entirety of the code? What line is the actual error on.

vikingstrike
Sep 23, 2007

whats happening, captain
That code works for me:

code:
In [1]: import pandas as pd                                                     

In [2]: %paste                                                                  
def generate_df():
    df = pd.DataFrame({'user': ['bob', 'jane'],
                 'income': [20000, 45000]})
    return df

## -- End pasted text --

In [3]: generate_df()                                                           
Out[3]: 
   user  income
0   bob   20000
1  jane   45000

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Tortilla Maker posted:

Newbie question:

I'm currently getting the following error:


code:
def generate_df():
    df = pd.DataFrame({'user': ['bob', 'jane'],
                 'income': [20000, 45000]})
    return df
StackOverflow generally emphasized including 'return' but it doesnt seem to help. Other posts suggested placing this in a class but no luck for me either.

Appreciate any suggestions!

The fact that you talk about optionally including 'return' makes me think that particular line is not getting parsed as being part of generate_df and it's just floating out in the naked void. The paste looks fine but the original file might be different. What editor are you using for this? You might want to paste the code in from the post and try again since it looks like the paste has normalized the spaces.

Tortilla Maker
Dec 13, 2005
Un Desmadre A Toda Madre
Thank you all for the quick replies. And apologies for the poor explanation.

Issue is that I was attempting to call the dataframe elsewhere in my code.

For now, I can reference it by using "df = generate_df()" but I was hoping to just use the dataframe as it was defined inside the function (in this example, df).

Writing this on my phone and while on the go, so apologies for the poor example!

vikingstrike
Sep 23, 2007

whats happening, captain
Yeah, you need to assign the output of the function to a variable you then use later in the code.

lazerwolf
Dec 22, 2009

Orange and Black
Just as aside that function is pretty meaningless unless you are planning on doing additional processing to the dataframe before using it

code:
def generate_df():
    df = pd.DataFrame({'user': ['bob', 'jane'],
                 'income': [20000, 45000]})
    return df
is the exact same as writing this line
code:
df = pd.DataFrame({'user': ['bob', 'jane'],
                 'income': [20000, 45000]})
now if you plan to create a dataframe then do some filtering and return a subset of columns it might be more useful to define a function that would do those things to keep your code modular

code:
def generate_and_process_df():
    df = pd.DataFrame({'user': ['bob', 'jane'],
                 'income': [20000, 45000]})
    df = df[df['user] == 'bob']  # NOTE: do some filtering here
    return df
It would be more helpful if you included more of your code to see why you are getting the NameError.

lazerwolf fucked around with this message at 20:39 on Mar 10, 2020

M. Night Skymall
Mar 22, 2012

Tortilla Maker posted:

Thank you all for the quick replies. And apologies for the poor explanation.

Issue is that I was attempting to call the dataframe elsewhere in my code.

For now, I can reference it by using "df = generate_df()" but I was hoping to just use the dataframe as it was defined inside the function (in this example, df).

Writing this on my phone and while on the go, so apologies for the poor example!

What you're confused about is called scope, looking that up and reading about it might help understand why you can't use "df" outside of the function you're defining it in.

huhu
Feb 24, 2006
I'm so lost. I've got a file uploader in Flask that's intermittently uploading the file. I can't tell if this is one bug or multiple.

I've got a form:
code:
        <form method="post" novalidate>
            {{ form.hidden_tag() }}
            <div id="form_elements_wrapper">
                <div>
                    {{ form.photo.label }}
                    {{ form.photo }}
                </div>

		<!-- more code here -->
        </form>
Which goes to a route like so:

code:
@app.route('/', methods=['GET', 'POST'])
def stitch(): 
    form = StitchForm(request.form, meta={'csrf': False}) 
    if form.validate_on_submit():
        stitched_image = stitch_image(
            image=form.photo.data,
        )
    # ... more code
And the form looks like:

code:
class StitchForm(FlaskForm):
    photo = FileField(
        'Photo',
        validators=[
            DataRequired('The field photo is required')
        ]
    )
When I finally get that to the stitch_image function:

code:
def stitch_image(image):
    img = cv2.imread(image)
img ends up being None.

Further super weird behavior - I have an image in a directory and I can upload it just fine. However if I copy and paste it then try to upload the pasted image, it doesn't work.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

huhu posted:

code:
def stitch_image(image):
    img = cv2.imread(image)
img ends up being None.

Is image None?

Adbot
ADBOT LOVES YOU

huhu
Feb 24, 2006
Edit: I'm doing a bunch of dumb crap. Taking a break. Carrry on.

huhu fucked around with this message at 23:15 on Mar 10, 2020

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply