Pip安装成功但导入报ModuleNotFoundError:Anaconda与PyCharm冲突
Hey there! Let's work through why you're hitting an import error for Tweepy in PyCharm even though you've successfully installed it via pip. Here are the most common fixes to try:
Verify PyCharm is using your Anaconda Python interpreter
Since you installed Tweepy into your Anaconda environment, PyCharm might be pointing to a different Python version by default. To check:- Go to
File > Settings > Project: [Your Project Name] > Python Interpreter - Look at the interpreter listed at the top—does it point to
C:\Users\Student\Anaconda3\python.exe? - If not, click the gear icon >
Add > Existing environment, navigate to that Anaconda Python executable, select it, and save your changes.
- Go to
Install a Tweepy version compatible with Python 3.6
Python 3.6 is quite old, and newer Tweepy releases no longer support it. Try installing a version that works with 3.6:
Open your Anaconda terminal (or the command prompt linked to your Anaconda Python) and run:pip install tweepy==3.10.0This version is confirmed to work with Python 3.6. After installation, go back to PyCharm and refresh the interpreter dependencies.
Refresh PyCharm's package index
Sometimes PyCharm doesn't immediately detect newly installed packages. On thePython Interpretersettings page, click the circular refresh icon in the top-right corner. Wait for the index to update, then try importing Tweepy again.Check for project-specific virtual environments
If your PyCharm project is using a virtual environment, the Tweepy you installed globally (in Anaconda) won't be available here. You have two options:- Switch your project interpreter to the global Anaconda one (follow the first step above)
- Activate your project's virtual environment in PyCharm's built-in Terminal, then run
pip install tweepy==3.10.0to install it locally.
Give these steps a try—one of them should get your Tweepy import working in PyCharm!
内容的提问来源于stack exchange,提问作者user8949562

