篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Mac 10.14(Mojave)上的Python3.7设置相关的知识,希望对你有一定的参考价值。
1) Install Python 3.7.x from <https://www.python.org/downloads/> or via [homebrew](http://brew.sh/).
```
$ brew install python3 # Installed at /usr/local/Cellar/python3
```
Check that python3 has been installed by running it at the terminal:
```
$ python3
>>> Python 3.7.2
```
2) Download `get-pip.py` from <https://bootstrap.pypa.io/get-pip.py> and install (this should already be installed if python was installed from python.org or homebrew):
```sh
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py
```
3) Install virtualenv and [virtualenvwrapper](http://virtualenvwrapper.readthedocs.io/en/latest/install.html)
```sh
$ sudo -H pip3 install virtualenv
$ sudo -H pip3 install virtualenvwrapper --ignore-installed six
```
4) Add the following to your `~/.bash_profile` to load virtualenvwrapper then run `bash -l`
```sh
# Location of python virtual environments
export WORKON_HOME=$HOME/.virtualenvs
if [ -e /usr/local/bin/virtualenvwrapper.sh ]; then
source /usr/local/bin/virtualenvwrapper.sh
fi
```
5) Create your virtual enviornment named `py3`
```sh
$ mkvirtualenv --python=`which python3` py3
```
/*
* To install all modules: pip3 install -r requirements.txt
*/
bokeh
Flask
ipython
jupyter
keras
matplotlib
nose
numpy
pandas
Pillow
pymc
requests
scikit-image
scikit-learn
scipy
seaborn
statsmodel
tensorflow
Installing [opencv](http://opencv.org) with python3.7
```sh
$ brew update
$ brew install opencv@3 --with-python3 # Add --with-contrib if you want the contrib modules
$ ln -s /usr/local/Cellar/opencv/3.4.5/lib/python3.7/site-packages/cv2/python-3.7/cv2.cpython-37m-darwin.so /usr/local/lib/python3.7/site-packages/cv2.so
```
You may have to export `PYTHONPATH`:
```sh
export PYTHONPATH=$PYTHONPATH:/usr/local/Cellar/opencv/3.4.5/lib/python3.7/site-packages
```
If you installed a previous version of opencv and no longer need it, remove it:
```
brew cleanup opencv
```
Test:
```
$ python3
In[1]: import cv2
In[2]: cv2.__version__
Out[2]: '3.4.5'
```
Install these modules from Github as their py3 support is currently not published on PyPI.
Their master branch works with Python3.7
Set your locale in an environment variable in `~/.bash_profile`
```sh
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
```
Type `bash -l` in your terimal to run the updated bash_profile.
Now, install the modules:
```sh
$ pip3 install git+git://github.com/cython/cython@master
$ pip3 install git+git://github.com/statsmodels/statsmodels
$ pip3 install git+git://github.com/pymc-devs/pymc3
```
```sh
$ brew install llvm
$ brew link llvm --force
$ pip3 install numba
```
Test code from [numba](http://numba.pydata.org)
以上是关于markdown Mac 10.14(Mojave)上的Python3.7设置的主要内容,如果未能解决你的问题,请参考以下文章