---
# System prepended metadata

title: Commands for macOS

---

# Some Commands for macOS

## gym box2d

```python
pip3 install 'gym[all]'
pip3 install swig
pip3 install 'gym[box2d]'
```

If there is an error like,
```python
ERROR: Could not build wheels for box2d-py, which is required to install pyproject.toml-based projects
```
Check if your pip address is in PATH. If not, like,
```python
WARNING: The script swig is installed in '/Users/wei/Library/Python/3.9/bin' which is not on PATH.
```

1. Open your terminal, and input it: 
```python
open ~/.zprofile
```
or
```python
open ~/.bash_profile
```
2. In the zprofile or bash_profile, input this code. Then save it, and close. **If you save it in zprofile, just save it and close terminal**. And open terminal again! Finish!
```python
export PATH="/Users/wei/Library/Python/3.9/bin:$PATH"
```

3. In your terminal, input it: 
```python
source ~/.bash_profile
```
4. Check if success.
```python
echo $PATH
```
Now, install 'gym[box2d]' again.
```python
pip3 install 'gym[box2d]'
```

## Install Atari game
Input the following code in your terminal:
```python
pip3 install 'gymnasium[atari]'
pip3 install 'gymnasium[accept_rom_license]'
```
If error, please check your PATH!

## Open tensorboard
Input the following code on your terminal.
```python
python3 -m tensorboard.main --logdir=./
```

## Export your conda env
(This is for windows)
First, you need to open your terminal and input the following code:
```python
conda activate YOUR_ENV_NAME
```
And input this code to export, then you get a file.yml of pip list in your environment.
```python
conda env export -f test.yml --no-builds
```
If you want to create another environment on another computer like your original one, input this code in CMD, not your enviroment. Yoy would get an environment named "YOUR_ENV_NAME" is the same as the original one.
```python
conda env create --file test.yml
```

## Homebrew

### Install Homebrew
https://brew.sh/
```python
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
### Uninstall homebrew
https://github.com/homebrew/install#uninstall-homebrew
```python
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
```

## Tesseract


### Install tesseract
```python
brew install tesseract
brew install tesseract-lang
```

### Install pytesseract
```python
pip3 install pytesseract
```

### Use it
```python
import pytesseract
from PIL import Image
img = Image.open('YOUR_IMAGE.png')
text = pytesseract.image_to_string(img, config='--psm 10')
print(text)
```