1

I'm trying to reforce the installation of the package inside of my code. For that I've this:

import sys
import subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", 'JPype1==0.6.1 --force-reinstal'])
subprocess.check_call([sys.executable, "-m", "pip", "install", 'mysqlclient pymysql'])

However, I am getting the following error:

ERROR: Invalid requirement: 'JPype1==0.6.3 --force-reinstal'
subprocess.CalledProcessError: Command '[python.exe', '-m', 'pip', 'install', 'JPype1==0.6.3 --force-reinstal']' returned non-zero exit status 1.

Anyone have a solution? Thanks!

1
  • 1
    Make sure to correctly split the arguments: 'JPype1==0.6.1', '--force-reinstall' and 'mysqlclient', 'pymysql'. Commented May 4, 2020 at 12:00

1 Answer 1

1

The issue is subprocessing requires a separate argument for each argument being sent to the command. Also, 'reinstall' is spelt wrong. The correct code is as follows, where each argument is separate and the typo is fixed:

import sys
import subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", 'JPype1==0.6.1', '--force-reinstall'])
subprocess.check_call([sys.executable, "-m", "pip", "install", 'mysqlclient', 'pymysql'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.