Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6140

How to Alias `python` to Python 2 (`/usr/bin/python2`) on WSL Ubuntu? [closed]

$
0
0

Context:

I am trying to compile JModelica Ubuntu (running on WSL - Windows Subsystem for Linux) and facing a challenge with Python version conflicts. The compilation process requires Python 2, but by default, python on my system refers to a Python version managed by pyenv, specifically located at /mnt/c/Users/<userName>/.pyenv/pyenv-win/shims/python. This setup leads to errors during the JModelica compilation process, such as:

make[2]: Entering directory '/mnt/c/dev/JModelica/build'...python setup.py install --with_openmp=True .../mnt/c/Users/<userName>/.pyenv/pyenv-win/bin/pyenv: 3: cygpath: not found/mnt/c/Users/<userName>/.pyenv/pyenv-win/bin/pyenv: 3: exec: cmd: not foundmake[2]: *** [Makefile:1020: build-python-packages] Error 127...

The compilation fails because it attempts to use the Python version managed by pyenv, which seems incompatible with the expected environment. Running which python confirms that python points to the pyenv shim: /mnt/c/Users/<userName>/.pyenv/pyenv-win/shims/python.

Question:

I have installed Python 2 using sudo apt install python2, and which python2 correctly points to /usr/bin/python2. However, I am unsure how to alias python to /usr/bin/python2 across the system or specifically for the JModelica compilation process, bypassing pyenv.

I have tried temporarily aliasing python to python2 in my current shell session

alias python=/usr/bin/python2

and adjusting the PATH environment variable so that /usr/bin takes precedence over the pyenv shims directory

export PATH=/usr/bin:$PATH

but neither approach resolves the issue during the JModelica build process.

Could someone guide me on how to force the Ubuntu operating system to recognize /usr/bin/python2 as the default python interpreter, especially for compiling JModelica, or how to adjust the build process to use the correct Python version?

Update:

Unfortunately, this post is being attacked by some spam users; hence, I cannot post an answer. Temporarily, I will add my solution so far as an update:

  • installed pip via sudo apt install python-pip
  • then python2 -m pip install virtualenv
  • create a virtual environment with Python 2 isolated from system's default Python ~/.local/bin/virtualenv --python=/usr/bin/python2 jmodelica_env
  • then activate the virtual environment to use the isolated Python installation within it source jmodelica_env/bin/activate

Viewing all articles
Browse latest Browse all 6140

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>