r/Python • u/ECrispy • Oct 25 '18
A tale of caution, and how I realized how common Python is
A few days ago I decided to install the newest versions of Python (3.7.1) and PyCharm (since I saw the community edition is free). I use my Windows 10 pc for a lot of tasks and have a number of utilities (downloaders, file renamers etc) installed.
Some of you can probably see where this is going. Well, all hell broke loose and stuff started breaking. I was restarting programs and services, checking configs etc and had no clue. At this point of course I had not made the connection with installing new Python.
Then I somehow noticed task manager would show PyCharm running even though I'd closed it or never started it. In a stroke of brilliance (haha, more like luck) I realized this was because .py files were associated with it (I must've checked that option or it was defaulted) and thus all Python scripts would fail. On top of that I found that many older scripts break from 2->3.
What was surprising is how many programs use Python under the hood.
edit - A lot of people have attacked me and outright accused me of lying. This is what I did - I am using Nzbget as a download program, I installed newer Python and PyCharm which took over the .py extension and nzbget stopped working till I uninstalled both and reinstalled Python 2.7.
I am fully aware this may be specific to Windows or that particular program, but nowhere did I insinuate that Python was to blame. I really didn't expect to be attacked and to be called a liar. That is in no way justified.
28
Oct 25 '18
Did you make this up? This shouldn’t be how it works. Windows does not come with a python interpreter so amongst other reasons under windows python utilities always bundle their own interpreter.
12
u/13steinj Oct 25 '18
He's either not being clear or a complete bullshit artist
he is talking about his own scripts. This makes sense-- he installed Python, he ran the files in some way that used windows file semantics to link against the interpreter instead of calling the interpreter and the script directly as a module. Now he imstalled PyCharm, windows defaulted to setting PyCharm as the default opener, his scripts won't open.
he's talking about other people's stuff, ex dropbox or mutorrent (or is it bittorrent? I forget?), in which case he's an utter bullshit artist because those programs bind to their own interpreter/subset of the runtime.
0
u/ECrispy Oct 26 '18
You are a piece of work my friend, accusing people without any evidence.
1
u/13steinj Oct 26 '18
The evidence is everyone's experienfe in this thread. Whereas i will eat my hat if you can provide a counter, you're not.
-4
u/ECrispy Oct 25 '18
No, I installed PyCharm and it took over .py which broke other prgrams that used Python. Why would I make this up?
1
Oct 25 '18
You tell me lmao
4
u/13steinj Oct 25 '18
Saying anything good about Python has recently been easy karma. "Here's my first python script! I'm so proud!" >> got 200 pts in a few hours.
1
Oct 25 '18
Maybe I will make a post about the hundreds of lines a day of sphaghetti python I churn out if it’s really such a karma farm
20
u/atenni Oct 25 '18
A quick point of clarification to help python newcomers: a few comments here recommend virtualenv which, while a great tool, wouldn't have helped OP.
Tools like
virtualenv|pipenv|venvhelp with application and library isolation.A tool like
pyenvwill help with python version isolation. This would have helped OP avoid messing up his OS installed python in this instance.
On Windows I'm told that pyenv works very well under Windows Subsystem for Linux, assuming you have Windows 10 Anniversary edition or newer.
5
u/atenni Oct 25 '18
This great stackoverflow answer goes into more detail on the current state of python packaging.
0
u/ECrispy Oct 25 '18
I do have WSL in Windows 10. Some people have recommended Anaconda which I have no clue about. Very confused now about how to keep my tools working and also get an IDE and Python for dev work using v3.
1
u/dickloraine Oct 25 '18
As a quick solution, you could use py.exe to open py files. You can then just add a shebang to your scripts specifying the python version to use. You can read more about it in the python documentation under python on windows.
27
u/coffeecoffeebuzzbuzz Oct 25 '18
This. It's doubly important on Mac where a lot of underlying glue code in the OS is Python. Using isolated Python installs and things like venv and virtualenvwrapper can save you from a world of hurt.
3
u/ECrispy Oct 25 '18
What do I do on Windows? I want to use newer python without breaking tools.
29
8
u/wpg4665 Oct 25 '18
Check out Anaconda, or miniconda for a lighter install. Pretty much a necessity on Windows.
1
u/CaptKrag Oct 25 '18
Ya. I haven't made the attempt in a while, but attempting to install anything that requires compilation in Windows via pip is a huge pain in the ass unless you're extremely comfortable with Ms build tools and willing to download a whole bunch of unsupported versions for older versions of Python from random sites. You'll save hours or days by just using anaconda because of the prebuilt binaries.
1
2
u/victoriabittahhhh Oct 25 '18
open up a command prompt, go to a folder, and type
python -m venv venv- this creates a clean virtual environment in a folder called venv.In PyCharm, you can press
ctrl + shift + ato open the quick search and type "project interpreter". In that, addvenv\scripts\python*.exeas the interpreter.1
u/gardens_of_slish Oct 25 '18
You might have added Python 3.7 to your PATH when installing, you want to avoid that generally unless you're sure you need it. May have been a checkbox that came up in the installer.
1
Oct 25 '18
Switch to linux, jk, but just be a little more careful. If you want to use the newer python, I would just recommend separating your scripts by version and making sure you execute python or python3. If you want to debug and test what works and what not it sounds like you should run a VM.
1
u/ProfessorPhi Oct 25 '18
I think the important stuff in OS X is tied to the system python which only uses in built packages.
1
u/chief167 Oct 25 '18
after years of coding on a mac, going from total python noob to doing experimental shit and having a mess of native Python, Brew, Anaconda, Macports and everything active at the same time, I have never been able to damage/fault another program.
It is messy, but it is pretty robust.
4
u/driscollis Oct 25 '18
This doesn't happen on Windows. I have been a Windows and python user for many years and never seen this.
However you can totally jack up linux or Mac by installing a newer system Python
1
3
u/robberviet Oct 25 '18
That's really weird. Windows services or softwares does not relies on Python.
I am using Mac but it's not even that bad. I think you should recheck.
Unless you are talking about custom ones installed by you or your projects, then it's your fault. Always using separated environments.
0
u/ECrispy Oct 25 '18
Nothing in Windows does. 3rd party utils do. And how is it my fault? You can install a program and it can break other stuff. The programs don't even mention they depend on Python.
5
u/13steinj Oct 25 '18
There are no end-user facing third party utilities that automatically bind to a python executable unless they provide it itself in some kind of archival format.
If you claim such, give examples and we can disprove in a heartbeat.
You're bullshitting for karma.
-3
u/ECrispy Oct 25 '18
A util you install can come bundled with its own dependencies and sometimes they use python scripts. Then a user can install something that takes over the .py extension and break the util.
You don't have to believe me, I honestly don't care, but don't accuse me of lying. I have better things to do than write such a detailed post, which I did to ask for help and to learn.
1
u/13steinj Oct 25 '18
I accuse you of lying because it's beyond obvious that you are. To lie about the inner workings of basic development information on a fucking programming subreddit is an idiotic thing to do!
Your post wasn't "detailed"-- it was a few paragraphs of utter fluff and "oh my god python is great look so many things use it".
So either prove it or admit your falsehoods.
1
u/robberviet Oct 26 '18
If you have a problem, describe it with details.
If your post has tons of people bashing you about you are misleading and not provide enough information, or even lying, just edit and update some more information (how do you manage interpreter, PATH, env, etc.)
The problem might be correct and devastating to you, but there is a reason why everybody in this thread is against you.
2
3
Oct 25 '18
I don't think it's intentional, but something's missing here. That should not normally happen and there's something funky with your system.
0
4
Oct 25 '18
I don't know if it's still the case, but re-aliasing python in Ubuntu to 3 from 2 (or the other way around, I forget which) caused loads of stuff to break. Learnt that one the hard way More than once
3
u/M374llic4 Oct 25 '18
Pycharm automatically can setup a virtual environment for you. It's good stuff.
1
u/Laserdude10642 Oct 25 '18
with great power comes great responsibility. i think most of us linux users have broken architectures before by messing with config files and downloading/replacing things on the computer. its a hard lesson to be learned
3
Oct 25 '18
Doing a lot of infrastructure programming on all sorts of flavors of Linux, I'd say that broken dependencies is not the most outstanding feature of programs written in Python. Poor code quality dominates that. I've ran into a lot of bugs in programs endowed with a lot of responsibility, like
feduporyumoranaconda(the installer, not the alternative Python build).But, to put the credit where it's due: Python's package management is a pile of steaming poop, so, it's not surprising that programs break once unrelated things get updated. Especially in the light of a lot of large projects cannot even get their own dependencies sorted out and knock themselves over without any external help from crafty users messing with them. For example,
azure-clias of today, is, in principle, not installable bypip, even though it's all on pypi.org. If you look at it from up close, it's a perfect example for case studies of everything that's wrong with Python packaging and distribution.0
u/ECrispy Oct 25 '18
You know, I've read so much praise about pip and how its comparable to npm but in my experience npm is so much better and it just works all the time, for really big projects as well.
1
u/Laserdude10642 Oct 25 '18
I’m not really referring to npm or pip breaking architectures- I’m referring to users making root/admin level changes and not understanding how their changes will affect the system. While I hope these big package handlers like npm or pip wouldn’t let me break my own system, it’s foolish to trust the programs and you should understand what changes you are making.
1
Oct 25 '18
It's not foolish to trust programs. You trusted your browser to post your message to this thread, right? You didn't call Reddit developers and asked them to verify that your post was actually saved, replicated, archived etc. in all the required edge servers and caching servers, did you?
You just assumed that the function of this text box is to let you type it, and that it doesn't distort your message and that the function of the "reply" button is to initiate the sending of your message and so on. Users have certain expectations of programs, and they should trust them to live up to those expectations, otherwise they wouldn't be able to do any work on a computer at all.
What I'm saying is that Python users, generally, expect the packaging system to produce sane results... and that often times it doesn't live up to that expectation. I don't have any statistics at hand, but I'd imagine that the number of times anyone screwed up their system through a mistake (such as oversight, misunderstanding of functionality etc.) would be less than the number of times when desired and expected functionality wasn't there, when things that should be obvious to everyone were somehow not obvious to the person writing the program. And example of that is how
pipinstalls packages: for no real reason it only allows one version of a package, while also precluding Python programs from declaring which versions of installed packages they need. This is counter-intuitive because the need is so obvious nobody would really think that a sane programmer would have not done it this way, and yet...
2
-2
u/tunisia3507 Oct 25 '18
And this is why we use virtual environments.
Although I actually managed to trash my system python while still using virtualenvs - something to do with following symlinks while deleting a virtualenv directory. I was on ubuntu, so apt broke, I ended up reinstalling the whole OS (it needed doing anyway).
Now I use pyenv. It's saved me a lot of hassle. No windows equivalent, though (use a better OS).
-1
u/Silver5005 Oct 25 '18
Im just gonna say it, fuck windows. Never realized how shitty the OS was until I got into programming.
108
u/Deto Oct 25 '18
I didn't think any Windows programs just looked for a Python.exe on the path and used it? I thought they all bundled their own Python for exactly this reason (and the fact that Python doesn't come with Windows standard).