"ImportError: cannot import name 'FastMCP'" I stared at this for way too long. The library was installed. The version was correct. The import path was right. pip install mcp → success from mcp.server import FastMCP → ImportError Here's what happened: My project had a folder called mcp/. Python found it first. That's it. Python's import system checks the local directory before installed packages. My mcp/ folder — which held config files — was silently hijacking every import call. The fix was one line: sys.path.remove(os.path.dirname(__file__)) The debugging? Over an hour of reinstalling packages, checking versions, and questioning my sanity. Name your folders carefully. Python's import system doesn't care about your intentions — only your directory structure. If your installed package suddenly "can't be found," check if you accidentally created a folder with the same name. Ever had a naming collision silently break your project? #Python #Debugging #DeveloperLife #SoftwareEngineering
Arnab Bhakta’s Post
More Relevant Posts
-
Claude Opus 4.7 just dropped and I have to say I am disappointed. Poor Behaviors from today: - Asking questions in plan mode then completely ignoring the answers when generating the code. "I'm sorry I was exercising an abundance of caution when ignoring your answer" (note I asked it not to build an image on every single code commit) - Creating wildly elaborate and hacky solutions to simple problems. claude wanted to insert a bash script into cicd to manually traverse a node repo and hack in version.ts files to fix an issue where a module depending on another that hadn't been built yet. "You are right. That is an overly complicated solution and not appropriate for production builds" - Choosing to write elaborate python scripts and asking permission to execute for very simple plugin tasks like doing a code diff from a pr. "You are right, I should just use the gh plugin"
To view or add a comment, sign in
-
I’ve been spending my recent free time in building an Event-Driven Backtesting Engine from scratch for Options. Backtesting complex option strategies requires processing massive amounts of market data, calculating Greeks, and tracking portfolio metrics simultaneously. To handle this without latency bottlenecks, I decided to architect the entire core engine in C++. for now I have mostly tried to make it very flexible like modular commission and slippage and ability to write custom strategies instead of editing the core engine itself I completely decoupled most of the core things so The entire C++ backend is compiled as a standalone library. I am also trying to Integrate a python bridge using pybind11 exposing this compiled library directly to Python. The goal for this is to make the engine to do all the computation in the background, allowing anyone to write, test, and plug in custom strategies dynamically using simple Python scripts without ever needing to modify the core engine files. Getting the C++ event loop to work good with Python scripting is proving to be a little complicated right now! I'll be pushing a final README and some sample strategies once I get the bindings fully stabilized. You guys can check out the code here : https://lnkd.in/gRSgd4gs #quantfinance #cpp #python #algorithmictrading #options #pybind11 #derivatives
To view or add a comment, sign in
-
-
Mutable default arguments — the bug that's been in your code for years Most Python developers have shipped this bug. They just don't know it yet. def add_item(item, items=[]): items.append(item) return items Looks innocent. Isn't. Most people think the empty list is created fresh on every call. It's not. The default value is evaluated exactly once — when the function is defined. The same list object is reused on every call where you don't pass items explicitly. Call it three times without arguments and you don't get three lists with one item each. You get one list with three items, growing across every call you forget to make. In production this shows up as: a function that caches results between requests when you didn't ask it to. State leaking across users. Tests that pass alone and fail in a suite. The fix is one line: def add_item(item, items=None): if items is None: items = [] items.append(item) Mutable defaults are not a feature. They're a sharp edge. Sentinel-and-rebuild is the only safe pattern. #PythonInternals #Python #DataEngineering #SoftwareEngineering #Developer #PythonDeveloper #Backend #CodingInterview #Developers #Programming #Learning #PythonTips
To view or add a comment, sign in
-
Built my first MCP server this weekend just to understand how they work. The idea was simple to start: connect Claude to my Gmail, Google Calendar, and a local task DB, then ask it "what do I need to know?" It came back with a full Sunday rundown , unread emails triaged by priority, tomorrow's stand-up, pending tasks. One question, actual context from my real data. The interesting part wasn't the output. It was realizing how MCP works under the hood, you're just exposing Python functions as tools over stdio. Claude decides when to call them and how to combine the results. Repo if you're curious: https://lnkd.in/dRNNVgxS
To view or add a comment, sign in
-
-
One source of friction in C++/Python projects isn’t the code itself. It’s the infrastructure around it. Build systems. Test runners. Docs. Linters. Packaging. CI. You’re not just running one workflow. You’re managing all of them: • Build Python • Build C++ • Test Python • Test C++ • Generate docs • Lint and format • Package and deploy And each step brings its own tool: CMake, scikit-build, pytest, ctest, ruff, twine... After a while, every repo ends up with its own mix of tools, scripts, CI steps, and half-remembered commands. I built foga to reduce that friction. foga lets you define your entire workflow in a single foga.yml and run it through one CLI. It has been shaped and tested against real project layouts like NumPy, Arrow, and pybind11. One config. One CLI. Less glue code. Less context switching. If you’ve felt this pain, I’d love your feedback: https://lnkd.in/dU2K5hZ3
To view or add a comment, sign in
-
𝐃𝐚𝐲 𝟔/𝟑𝟎: 𝐇𝐨𝐰 𝐝𝐨 𝐏𝐲𝐭𝐡𝐨𝐧 𝐝𝐞𝐯𝐬 𝐡𝐚𝐧𝐝𝐥𝐞 𝐭𝐡𝐢𝐬? 🐍 Coming from C++, I’m used to the compiler being my safety net. If I try to add a string to an int there, the code won’t even run. ➡️ But yesterday I realized Python is... a different world! def add(a, b): return a + b add(10, "5")💣 Boom! Runtime Error In a tiny script, this is a 2-second fix.. But in a massive codebase with thousands of functions? This feels like a 𝐡𝐢𝐝𝐝𝐞𝐧 𝐫𝐢𝐬𝐤 𝐰𝐚𝐢𝐭𝐢𝐧𝐠 𝐭𝐨 𝐡𝐚𝐩𝐩𝐞𝐧. So, the real question for the experts here: How do you guys stop these "sneaky" errors before they hit production? Is it: A) Just remember everything B) Test everything thoroughly (Unit tests for every single edge case) C) Use Python type hints (a: int, b: int) (👀but do they actually stop the crash?) D) Something else(MyPy? Pylint?) I’ve been digging into this 𝐜𝐥𝐚𝐬𝐡 𝐛𝐞𝐭𝐰𝐞𝐞𝐧 𝐟𝐥𝐞𝐱𝐢𝐛𝐢𝐥𝐢𝐭𝐲 𝐚𝐧𝐝 𝐬𝐚𝐟𝐞𝐭𝐲 𝐭𝐨𝐝𝐚𝐲. I’m hunting for a way to make Python feel just as safe as C++. I'll share what I find tomorrow! Drop your choice below 👇 What’s the standard industry workflow for catching these? #Python #Cpp #LearningInPublic #30DaysOfCode #SoftwareEngineering #Programming
To view or add a comment, sign in
-
-
Built a web-based network scanning tool using Python and Flask. It performs multi-threaded port scanning and shows results in a browser dashboard with live progress, scan history, and export options. I also added a simple risk analysis layer that gives a short explanation for each open port, along with basic safety controls to restrict unintended scans. Features: - Multi-threaded TCP scanning - Browser UI with real-time results - Scan history stored in SQLite - Export reports (TXT, JSON) - Safe mode for controlled usage GitHub: https://lnkd.in/gKDBtUs3
To view or add a comment, sign in
-
🚀 Just Published My First Python Library on PyPI! Excited to share that I’ve built and published "common-fun" — a modular Python utility library designed to simplify everyday development tasks. 📦 Install: pip install common-fun 🖥️ Try CLI: common-fun help 🔗 GitHub: https://lnkd.in/gjWRyhpq 🔧 What it includes: • Number utilities (prime, gcd, factorial, etc.) • String processing (palindrome, slugify, etc.) • Array helpers (flatten, chunk, rotate) • Validators (email, URL, password) • File utilities • Performance decorators (timer, retry, caching) • 🔥 CLI support for direct terminal usage 💡 Why I built this: While working on multiple projects, I realized I was repeatedly writing similar utility functions. So I decided to consolidate everything into a clean, reusable, and structured library. ⚙️ Key highlights: • Fully modular architecture • Optimized implementations • CLI tool for quick access • PyPI-ready packaging • Clean documentation This project helped me understand: ✔️ Library design ✔️ Packaging & publishing ✔️ CLI development ✔️ Clean code practices Would love your feedback and suggestions! #Python #OpenSource #Developer #Programming #PyPI #SoftwareDevelopment
To view or add a comment, sign in
-
Most AppSec programs have a blind spot. Python and npm dependencies? Tracked and patched. The C and C++ (C/C++) code powering your OS, firmware, and real-time systems? A blank space where the risk assessment should be. The problem isn't complexity. It's that most tools were built around the assumption that dependencies are declared somewhere machine-readable. In C/C++, that assumption fails. Alexandra Selldorff wrote about why and what getting it right actually looks like. https://lnkd.in/gDPd-KPQ
To view or add a comment, sign in
-
Type errors in Python only surface when the faulty code path actually executes at runtime. A function that receives the wrong argument type can pass an entire test suite — then fail in production on a condition nobody anticipated. mypy catches that class of error before any code runs. But many articles stop at "add annotations and run mypy." The mechanics of how it actually works stay opaque. The article linked below (on PythonCodeCrack) goes further: — The full analysis pipeline: AST parse → import resolution → type inference → contract checking, with no execution involved — How gradual typing works in practice, including what the Any type actually does to mypy's analysis downstream — A precise look at type narrowing and control flow analysis — with an interactive diagram showing how isinstance() resolves str | int into concrete types per branch — The difference between # type: ignore and cast() — and why using the wrong one silently breaks your type guarantees for all code that follows — What mypy 1.20 changed: the narrowing engine rewrite, fixed-format cache as the new default, and the experimental Ruff-based parser — How pyright and ty differ from mypy architecturally — not just in speed benchmarks, but in evaluation strategy and what that means for unannotated legacy code Written for developers who want to understand the tool, not just run it. https://lnkd.in/e838Mdu5 #Python #SoftwareEngineering #TypeHints
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development