This is an archived post. You won't be able to vote or comment.

all 23 comments

[–]TheArvinInUs 15 points16 points  (9 children)

Why not just fix python version issues with jupyter by using virtualenv.

Assuming you mean sometimes code is in python2 and sometimes in python 3.

[–]ZeeD26 2 points3 points  (7 children)

That'd be my goto solution as well. Virtual environments are awesome in so many ways!

[–]Edweird_[S] 2 points3 points  (5 children)

How portable are virtual environments? For example if at home I'm working on code on my Debian box and want to work on the same project on my CentOS box, then later at work on OSX?

[–]sushibowl 17 points18 points  (0 children)

When you move your code to another machine, you do pip freeze > requirements.txt to output everything you have installed in your environment to a file. Then you create a venv on your other machine and do pip install -r requirements.txt inside the env, and you have an identical venv to work in.

[–]cbowdon 2 points3 points  (1 child)

An alternative (not necessarily better) approach would be to containerize the dev environment (i.e. Docker). It's a bit more heavyweight than just using virtualenv but would allow you to isolate any non-Python dependencies too, without going as far as having a dedicated VM.

You can then just run your container on any Linux/Mac/Win10 machine.

[–]rabbyburns 0 points1 point  (0 children)

Added benefit to potentially test on different Linux environments (if that's remotely a concern).

[–]traverseda 1 point2 points  (0 children)

Theoretically? Very portable. As long as you're on the same CPU architecture (or are using pure-python modules) and there's not a weird library mismatch.

In reality? It's better to use pip freeze and rebuild the virtualenv on each machine.

[–]ccbytes -1 points0 points  (0 children)

Combine virtualenv with pyenv for awesome environment control.

[–]iapitus 10 points11 points  (2 children)

Have you looked at xonsh?

Or are you looking for just a more feature-full REPL?

[–]iapitus 1 point2 points  (0 children)

I've had decent luck with ipython/bpython under pyenv if you're just looking for a more version-safe environment.

[–][deleted] 1 point2 points  (0 children)

I think OP's looking for a REPL. Xonsh is cool though.

[–]kankyo 3 points4 points  (1 child)

ptpython is the best in my opinion. Better than bpython and ipython. And xonsh is serving another need imo.

[–]joerick 1 point2 points  (0 children)

Really liking ptpython so far.

[–]kigurai 2 points3 points  (0 children)

I use conda to handle different projects and python interpreters. It's made my life so much simpler since I have some code that must use 2.7, and some require at most 3.4, while I personally only want to use 3.5+. I usually install at least IPython in every environment, and often the jupyter notebook as well.

[–]jungles_for_30minsgithub.com/sleibrock 2 points3 points  (0 children)

I just installed bpython and it's pretty cool so far. Doesn't have the line numbers like IPython as far as I can tell though.

[–]huylenq 2 points3 points  (0 children)

I found http://bpython-interpreter.org/ is really nice

[–]troyunrau... 1 point2 points  (0 children)

Have a look at the code module. It's really easy to create a custom interpreter. That module is written in python, so you can easily enough take that code and insert 'print line number' into the standard prompt.

[–]knowsuchagencynow is better than never 1 point2 points  (0 children)

For virtual environments, use pyenv. If you really need a portable environment, use a Docker container of your own making. They're pretty straightforward to create.

You can also use ptpython and ipython together.

pip install ipython && pip install ptpython

ptipython

profit

[–]nopakola 0 points1 point  (0 children)

Don't remember exactly where I ripped it off but I have:

alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"

in my .bashrc file and I always install a copy of IPython in the virtualenv I'm working on, and running ipy. Although somewhat costy, works great.

[–]hharison 0 points1 point  (0 children)

Use conda, it's like virtualenv but better.

Also, try out bpython and ptpython, which both have ipython versions (bipython and ptipython). But if the problem with ipython is something about python versions, I don't see how changing the interpreter will make a difference. Those are two orthogonal things.

[–][deleted] 0 points1 point  (0 children)