{"id":9237,"library":"pyslack","title":"pyslack","description":"pyslack is a Python API client for interacting with the Slack API. Last updated in September 2019 (version 0.5.0), it provides a synchronous interface for basic Slack operations. It has largely been superseded by the official and actively maintained `slack_sdk` library, which offers a broader feature set, asynchronous support, and better alignment with modern Slack API best practices.","status":"deprecated","version":"0.5.0","language":"en","source_language":"en","source_url":"https://github.com/kn/slack","tags":["slack","api-client","messaging","deprecated"],"install":[{"cmd":"pip install pyslack","lang":"bash","label":"Install pyslack"}],"dependencies":[],"imports":[{"note":"Despite the package name being 'pyslack', the importable module is 'slack'.","wrong":"from pyslack import Slack","symbol":"Slack","correct":"from slack import Slack"}],"quickstart":{"code":"import os\nfrom slack import Slack\n\nSLACK_API_TOKEN = os.environ.get('SLACK_API_TOKEN', 'YOUR_SLACK_API_TOKEN')\n\n# Ensure you replace 'YOUR_SLACK_API_TOKEN' with an actual legacy token or bot token\n# and 'CHANNEL_ID' with the ID of the channel you want to post to.\n# For modern Slack apps, consider using slack_sdk with Bot User OAuth Tokens.\n\nif not SLACK_API_TOKEN or SLACK_API_TOKEN == 'YOUR_SLACK_API_TOKEN':\n    print(\"Error: SLACK_API_TOKEN environment variable not set or is default. Please set your Slack API token.\")\nelse:\n    try:\n        client = Slack(token=SLACK_API_TOKEN)\n        \n        # Example: Post a simple message to a channel\n        response = client.chat_postMessage(\n            channel='CHANNEL_ID',\n            text='Hello from pyslack!'\n        )\n        \n        if response.get('ok'):\n            print(f\"Message sent successfully: {response.get('ts')}\")\n        else:\n            print(f\"Error sending message: {response.get('error')}\")\n\n        # Example: Get information about the authenticated user\n        user_info = client.auth_test()\n        if user_info.get('ok'):\n            print(f\"Authenticated as: {user_info.get('user')}\")\n        else:\n            print(f\"Auth test failed: {user_info.get('error')}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"Initializes the `pyslack` client with a Slack API token and sends a basic message to a specified channel, then performs an authentication test. This requires a Slack API token (e.g., a legacy token or a bot token) and a channel ID. For new applications, `slack_sdk` is recommended due to its modern authentication and feature set."},"warnings":[{"fix":"Migrate to the official `slack_sdk` library, which is actively maintained and supports current Slack API features and best practices. (pip install slack_sdk)","message":"pyslack is no longer actively maintained since its last release (0.5.0) in September 2019. It does not support modern Slack API features, authentication methods (e.g., Socket Mode, granular permissions via Bolt), or asynchronous operations.","severity":"breaking","affected_versions":"<=0.5.0"},{"fix":"For new development, use `slack_sdk` (and optionally `slack_bolt`) to ensure compatibility with current Slack authentication and app development paradigms.","message":"The library primarily relies on older Slack API token types. Modern Slack applications use Bot User OAuth Tokens and App-Level Tokens, often managed through the Slack Bolt framework, which `pyslack` does not natively support.","severity":"deprecated","affected_versions":"<=0.5.0"},{"fix":"Always use `from slack import Slack` for importing the client class after installing `pyslack`.","message":"The package is installed as `pyslack` but the module to import is `slack`. This can lead to `ModuleNotFoundError` if `from pyslack import Slack` is attempted.","severity":"gotcha","affected_versions":"<=0.5.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `pyslack` is installed: `pip install pyslack`. Verify your virtual environment is active.","cause":"The `pyslack` library is not installed in the current environment, or the Python interpreter is not pointing to the correct environment.","error":"ModuleNotFoundError: No module named 'slack'"},{"fix":"If you intend to use `pyslack`, ensure only `pyslack` is installed. If you intend to use `slack_sdk`, use `from slack_sdk import WebClient`.","cause":"This error can occur if you have the official `slack_sdk` library installed (where the client is `WebClient`) instead of `pyslack`, but are trying to import `Slack` from the `slack` module, which is the class name for `pyslack`.","error":"AttributeError: module 'slack' has no attribute 'Slack'"},{"fix":"Verify your `SLACK_API_TOKEN` is correct and has the necessary permissions. For new apps, generate a Bot User OAuth Token for your Slack app and ensure it has the required scopes. Consider migrating to `slack_sdk` for better token management.","cause":"The provided Slack API token is invalid, revoked, has insufficient scopes for the requested operation, or is a deprecated legacy token that is no longer active.","error":"slack.exceptions.SlackAPIError: invalid_auth"}]}