AKShare Installation Guide¶
This documentation is an English translation of the original AKShare documentation. The authoritative source for this project is the AKShare GitHub repository.
Back to original Chinese documentation →
Important Notes¶
-
Currently, AKShare only supports installation and use on 64-bit operating systems.
-
Currently, AKShare only supports Python 3.8 (64-bit) and above. We recommend Python 3.11.x (64-bit) version.
-
AKShare recommends installing the latest version of Anaconda (64-bit), which can solve most environment configuration problems.
-
For users familiar with container technology, Docker can be installed and used. See the tutorial: AKShare Docker Deployment.
Installing AKShare¶
Standard Installation¶
pip install akshare --upgrade
Note: When running the program, the filename and folder name cannot be "akshare".
China Installation - Python¶
For users in China, use the following command with Tsinghua mirror:
pip install akshare --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple
China Installation - Anaconda¶
For Anaconda users in China:
pip install akshare --upgrade --user -i https://pypi.tuna.tsinghua.edu.cn/simple
Upgrading AKShare¶
Note: Due to frequent version updates, please upgrade before using AKShare:
pip install akshare --upgrade -i https://pypi.org/simple
Apple Silicon (M-Series) Support¶
- AKShare now natively supports Apple M-series chips. Simply use:
pip install akshare --upgrade
- If compilation is required, please refer to: Building V8 on an M1 MacBook
Raspberry Pi Support¶
AKShare now supports installation and use on Raspberry Pi 4B. Installation method:
-
Install Raspberry Pi OS (64-bit) - currently supports the 64-bit version released on 20231010
-
Install virtual environment support:
sudo apt-get install python3-venv
- Create a virtual environment named "myenv":
python3 -m venv myenv
- Activate the virtual environment:
source myenv/bin/activate
- Install AKShare:
pip install akshare --upgrade
R Language Support¶
Installing Anaconda¶
Download and install Anaconda for your operating system.
Installing R Language¶
Install R for your operating system.
Upgrading R Language to Latest Version¶
Windows:
1. Open RGui as administrator
2. Run: install.packages("installr")
3. Run: installr::updateR()
Mac: 1. Install XQuartz 2. Run the following in terminal:
# Add Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add R Homebrew tap
brew tap homebrew/core
# Install R
brew install r
Installing R Packages¶
- Install the Anaconda environment first
- Open R in the Anaconda environment
- Install the following packages:
install.packages("reticulate")
install.packages("httr")
install.packages("jsonlite")
- Configure Python path in R:
library(reticulate)
use_python("/your/path/to/anaconda3/bin/python", required = TRUE)
MATLAB Support¶
Installing Anaconda¶
Download and install Anaconda for your operating system.
Installing MATLAB¶
Download and install MATLAB for your operating system.
Configuring Environment¶
- Open Anaconda Prompt (Windows) or Terminal (Mac/Linux)
- Create a new environment:
conda create -n akshare python=3.11
conda activate akshare
pip install akshare
- Open MATLAB and configure Python:
pyenv(Version="/your/path/to/anaconda3/envs/akshare/bin/python", ExecutionMode=1);
Testing Environment Configuration¶
% Test Python environment
py.print("Hello, AKShare from MATLAB!");
Testing AKShare Interface Calls¶
% Test without parameters
data = py.akshare.stock_market_summary();
disp(data);
% Test with parameters
data = py.akshare.stock_fundamental_flow(pyargs("symbol","600519","period","annual"));
disp(data);
Converting Data Formats¶
% Convert to table
data_table = table(data.Values, 'VariableNames', data.Properties.RowNames);
% Export to CSV
writetable(data_table, 'akshare_data.csv');
Troubleshooting Installation Errors¶
1. Installation Timeout Error¶
This is usually caused by slow network or timeout when downloading packages.
Solution:
- Use China mirror source: pip install akshare -i https://pypi.tuna.tsinghua.edu.cn/simple
- Increase timeout: pip install akshare --default-timeout=100
2. Permission Denied Error¶
Solution:
- Use user installation: pip install akshare --user
- Use virtual environment
3. Other Errors¶
If you encounter other errors:
- Check Python version:
python --version(must be 3.8+) - Check system architecture: Must be 64-bit
- Update pip:
pip install --upgrade pip - Install Visual C++ Build Tools (Windows)
See Also¶
- Introduction - Project overview
- Quick Start - Get started tutorial
- API Reference - Complete data interfaces
- Contributing - How to contribute