Error due to conflict between python when using gurobi

Problem and immediate solution

When I tried to execute a certain python file, I got the following error.

$ python [filename].py
Fatal Python error: PyThreadState_Get: no current thread
[1]    1588 abort      python [filename].py

By the way, the conditions were as follows.

--Other python files can be executed --It was feasible before the clean install --You are using an external library (gurobipy)

It was the type of error I saw for the first time, so I investigated what was the cause, and in a nutshell, (from the beginning?) Something went wrong between the python bundled with the Mac and the python installed with brew. It seems that they are in conflict with each other. I don't know the reason, but maybe it wasn't good that python managed it with brew.

By saying that, I have uninstalled python of brew.

brew uninstall python

This is the solution. You can now execute it safely. Probably the cause is that the versions of the two pythons are different (mac is 2.7.6 and brew is 2.7.9), and the path is not working well because of that, but I do not understand well. However, since the latest tasks are accumulated, I will pretend not to see it.

If anyone is familiar with it, I would appreciate it if you could easily tell me the cause.

Solution (additional note)

According to gurobi developer Greg Glockner, gurobi only supports python, which is installed by default on OS X. In other words, there is no choice but to downgrade brew python, uninstall (erase), or unlink (pause).

By the way, I decided to unlink. For the time being, simply

brew unlink python

Stop at and when necessary

brew link python

It's a translation to revive with, it's really easy! Or only when running gurobi in python

import os
os.system('brew unlink python')

(Execution content)

os.system('brew link python')

It may be easier to write like this.

I don't think it has been resolved, but I was refreshed because I somehow found the cause.

Recommended Posts

Error due to conflict between python when using gurobi
How to deal with OAuth2 error when using Google APIs from Python
Error due to UnicodeDecodeError when reading CSV file with Python [For beginners]
Error when trying to install psycopg2 in Python
How to exit when using Python in Terminal (Mac)
Error when executing Python commands without using Anaconda Prompt
What I was addicted to when using Python tornado
I get an error when I try to raise Python to 3 series using pyenv on Catalina
Post to Twitter using Python
Start to Selenium using python
Error when playing with python
Things to keep in mind when using Python with AtCoder
Things to keep in mind when using cgi with python.
List of libraries to install when installing Python using Pyenv
How to install python using anaconda
Things to watch out for when using default arguments in Python
Precautions when using pit in Python
Error when building mac python environment
[Python] Error and solution memo when using venv with pyenv + anaconda
Atom: Note for Indentation Error when copying Python script to shell
[Python] Be careful when using print
Unable to bind to interface error when using apollo federation with gqlgen
"Value Error: Unable to configure handler'file_output_handler'" when starting a python program
Error log output method when using Bottle framework on GAE / Python
Precautions when using phantomjs from python
When using MeCab with virtualenv python
Precautions when using six with Python 2.5
[VS Code] ~ Tips when using python ~
When using regular expressions in Python
How to deal with SSL error when connecting to S3 with boto of Python
[Python] What to do when an error related to SSL authentication is returned
Precautions and error handling when calling .NET DLL from python using pythonnet
From Python to using MeCab (and CaboCha)
Periodic execution processing when using tkinter [Python3]
Introduction to Discrete Event Simulation Using Python # 1
Favicon placement (when using Python, Flask, Heroku)
[python, multiprocessing] Behavior for exceptions when using multiprocessing
Log in to Slack using requests in Python
Syntax Error: invalid syntax due to double-byte space
Try to operate Excel using Python (Xlwings)
Dump BigQuery tables to GCS using Python
Introduction to Discrete Event Simulation Using Python # 2
Error, warning when using TensorFlow on Mac
When Python "Syntax Error: Non-ASCII character ~" appears
[Python] I want to know the variables in the function when an error occurs!
About the point that python 3.x got stuck due to an error due to caching_sha2_password
[python] What to do when an error occurs in send_keys of headless chrome
Is pyenv broken? Python 3.x references 2.x module at startup due to PYTHONPATH error
When using PyQtGraph with Python Pyside, pay attention to the order of import
Three things I was addicted to when using Python and MySQL with Docker
Output timing is incorrect when standard (error) output is converted to a file in Python
Things to keep in mind when using Python for those who use MATLAB
What to do if you get an error when installing python with pyenv
[Python] What to check when you get a Unicode Decode Error in Django
Error when installing a module with Python pip
How to start Python (Flask) when EC2 starts
#Monte Carlo method to find pi using Python
Procedure to use TeamGant's WEB API (using python)
Introducing 4 ways to monitor Python applications using Prometheus
[Introduction to Udemy Python 3 + Application] 38. When judging None
[Python] Precautions when assigning values to multidimensional arrays