Changed the version of python, but not reflected in pythonw - pythonw

I am trying to change the version of python that I'm running.
When i do python -V, it says 3.6 but if i do pythonw -V it is still running 3.7.
For this application, I need to run pythonw.
Is there a way to roll this back to use 3.6 (using OSX)?

You don't need to rollback anything.
Please take a look here.
There are several ways to define the version you want to run, from py launcher options to environment vars, ini settings, shebang lines, or even file type associations.

Related

Setting ruby version separately with different app on Mac

I have just started working on a ruby project and I notice that I have to specify the ruby version to use globally. For instance, I am using chruby to change the ruby version to use and I can set it directly at this file called .zshrc.
But if I have a multiple apps with different ruby version, then how do I handle it? It doesn't make sense if I keep changing the version to use at .zshrc file every time I want to run the other app.
Since it's a shared project so I cannot just change the version used in the app. Thank you.
In chruby, this feature is called "Auto-switching".
If you want chruby to auto-switch the current version of Ruby when you cd between your different projects, simply load auto.sh in ~/.bashrc or ~/.zshrc:
..
chruby will check the current and parent directories for a .ruby-version file.
https://github.com/postmodern/chruby#auto-switching

Where are hhvm command line flag definitions found?

When running phpunit 4.5 with hhvm inside docker sometimes it crashes the container. I'm not sure if I should alter the way I run hhvm on the command line or not. Are there any standards for running hhvm on the commandline?
So I'd like to get more familiar with hhvm's command line flags and definitions. Where can I find documentation on this?
I read on the https://codeascraft.com/2015/04/06/experimenting-with-hhvm-at-etsy/ that they used a tool called 'perf'. I don't seem to generate any perf.map files from the commandline. Browser requests have generated perf.map files though.
FYI
I've installed hhvm-nightly-dbg on ubuntu:14.10 to try to get more information when hhvm hangs on the command line.
My setup consists of the following
Mac osx Mavericks
Vagrant 1.7.2
VirtualBox 4.3.26
coreos-vagrant (running all containers with docker 1.5)
The containers are running
Redis:2.8.19
Mysql:5.1.73
hhvm-nightly-dbg
In our Ubuntu packages, configuration lives in /etc/hhvm/*.ini. Both files are loaded and combined when running in server mode.
Many INI options from PHP are available in HHVM with the same name. The HHVM-specific INI options are listed on the HHVM wiki; many are unfortunately missing documentation, though all of the important ones are there. There's a huge array of configurability here; you'll never need 99% of these.
/etc/init.d/hhvm controls the exact command-line options; you shouldn't need to modify this, set INI options instead.
Although you can pass any INI option to HHVM on the command line when not running in server mode, the mapping between command-line and INI syntax is weird and inconsistent for historical reasons. I'd strongly recommend just passing -c path/to/config.ini as a command line option instead, and just writing all your options in INI files. You can pass -c more than once; the files will be combined.

python, command line and windows path

I have added both python 2.7 and 3.4 to my system path. Personally I use python 3.4, however I use Vim as my editor and one of the plugins I use requires python 2.7 to be first in the path. This is annoying because now when I use the python command in the windows command line it loads python 2.7 rather than 3.4
Is there any way that I can add python 2.7 to the windows path just for vim? And make the command line load python 3.4?
EDIT: the plugin that requires python 2.7 is YouCompleteMe (https://github.com/Valloric/YouCompleteMe)
I needed this ability not because of Python versions but because of overbearing security policy. Where I work all persistent environment variables are privileged, so I put the following in my vimrc:
" Setup path
let $PATH.=';d:\python27;d:\python27\scripts'
let $PATH.=';d:\mingw\bin;d:\MinGW\msys\1.0\bin'
etc...
:help g:ycm_path_to_python_interpreter
In a doubt, reading the docs helps :)
A possible solution is to use a python version manager leave the system python version at 2.7 and install any other version you desire through the version manager.
An entire topic on python version mangers: https://stackoverflow.com/a/2812484/2745082
You can always rebuild the plugin to use python 3.4 if a version manger is to much trouble.

can not find ipy_user_conf.py for Enthought python

I have EPD. I would like to use the ipython shell. I think it's called 'pylab' in your distribution. I would like to be able to append to the system path ($pythonpath) at the moment when the shell loads. Unfortunately, I can not seem to locate the ipy_user_conf.py file that many users on the internet report is where I need to include a line to do that. Please help!!!
I'm going to guess that you're running IPython >= 0.11. (Note the IPython version is displayed when starting up the IPython shell.)
Older versions of IPython (pre-0.11) used ipy_user_conf.py, but IPython's configuration system was overhauled in 0.11. For details, see this overview. If you want to run some code on start up, you can add a python file in your IPython startup directory, which should be here:
~/.ipython/profile_default/startup/
Any python code in that directory gets run on startup, so you can just create a new .py to modify your python path. If the startup directory doesn't exist, you may need to run:
ipython profile create
which creates those directories (plus some other goodies).

How to change /usr/bin/env?

I have scripts that use #!/usr/bin/env ruby but I've switched to using Ruby Enterprise Edition instead of the default ruby that is included with Ubuntu server. Thus, the scripts freak out when I try to run them. How can I add the Ruby EE path to /usr/bin/env?
#!/usr/bin/env ruby is similar to simply calling ruby from the command line, so the same rules apply. Basically, the individual entries in the $PATH environment variable are checked in order, and the ruby that is found first is used. So make sure that the ruby for Ruby EE is earlier in the search path order than your other rubys.
I'm not familiar with Ruby EE, so if it doesn't have an executable called ruby, just create a symlink in a directory that's early in your search path to Ruby EE's executable.
Since you have an explicit dependency on Ruby EE, you could always modify the scripts instead of your environment ( which could have other unintended consequences ).
#!/usr/bin/env ruby
becomes
#!/path/to/enterprise/edition/ruby
Now it becomes clear to the reader that you using a specific version of ruby rather than just whatever ruby is in your path.
I had a similar problem where cron jobs stopped working... Cron seems to run commands by default without using the PATH settings you would expect for the user (when logging in as that user). In fact it didn't even seem to use any of the default PATH settings (be it in /etc/profile or elsewhere).
I was able to find the problem using the following commands (the first one is how cron seems to run commands):
su -c 'printenv PATH' userX
With output: /usr/local/bin:/usr/bin:/bin:/usr/games
su -l userX -c 'printenv PATH'
With output: /opt/ruby-enterprise-1.8.7-2010.02/bin/:/opt/ruby-enterprise-1.8.7-2010.02/bin/:/usr/local/bin:/usr/bin:/bin:/usr/games
The first command doesn't seem to populate the PATH variable in any way except for the bare system default.
In my case I solved it by just adding the necessary (REE) path to: /etc/login.defs, which by default looks as follows:
/etc/login.defs:103:ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/games
See section 1.6 in the Ruby EE documentation page:
http://www.rubyenterpriseedition.com/documentation.html
For a system wide change you can update your PATH in the /etc/environment file to include the Ruby EE bin directory. Maybe something like this:
PATH="/opt/ruby-enterprise-x.x.x/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
If you only want to the change to be visible for one user on the system you can update your .bashrc or .profile with the correct path.
Make sure to include the REE path first in the list of directories.
I posted the solution I used on Ubuntu here:
http://groups.google.com/group/emm-ruby/browse_thread/thread/d0c685bbd096823a#msg_effa7d6ad42c541c
There were some additional steps to get it working beyond what was described in the Ruby Enterprise Edition documentation.

Resources