ImportError after importing matplotlib - python

please could any one help!
Trying to import matplotlib I get this ImportError: *cannot import name 'artist' from 'matplotlib'*.
I removed the package (*py -m pip uninstall matplotlib*) and reinstall it but I still get the same error.
Thanks!

One of the common reasons why Python packages cannot be imported is because of its virtual environments. Basically when you install a package manager, it creates some root environment for you and you by default install all packages there. Now this issue may arise if you download a package into another VE, then in your code editor you should pick the one where it lies. I recommend you to check if your package is installed and pick that environment in the IDE, however from what I know it generates a different error message, something like the import couldn't be resolved. Did it help you?

Related

ModuleNotFoundError: No module named 'fpdf'

Getting this error: ModuleNotFoundError: No module named 'fpdf'
I've re-downloaded python, created a new venv and installed fpdf2 using pip install fpdf2, but I still get this error when I run from fpdf import FPDF
python version: 3.10.4
I've looked all over stack overflow and through the github issues and haven't found any solutions, and have no idea what to try next.
firstly please make sure that you want fpdf or fpdf2 lib, these are two different lib.
It seems that you want fpdf, so you need to try:
pip install fpdf
I was using VSCode's Jupyter extension and it wasn't using the same virtual environment that the terminal was using - so the install wasn't going to the right place. Once I aligned the two virtual environments, it worked fine.
This may be silly but should you be using fpdf2 instead of fpdf? Because if that's the name then it needs to be exact.
from fpdf2 import FPDF
Otherwise if you are using an IDE, then you may need to download the package into the IDE. For example in PyCharm I had to go to Python Packages and install it through there even after pip. Probably some path related issue.
Try pip install fpdf
With no 2.
Also make sure you're in the same env.

I have an error when installing the SpeechRecognition

pip install SpeechRecognition
I try to install SpeechRecognition with the command above but i get this message:
from http import cookies
ImportError: cannot import name 'cookies' from partially initialized module 'http' (most likely due to a circular import) (C:\Users\52644\venv\Lib\site-packages\django\http\__init__.py)
Can someone help me with this please.
I already solved it, in the directory variables I had one that I created that was named PYTHONPATH, you donĀ“t have to do that because python does that automatically, so you would have literally kind of a copy of all the files, that was producing the error. So, i just deleted that variable and it worked. Thanks fo the ones that answered.
While working with a large framework as Django one must always work in a virtual environment. Please check if you have your virtual environment activated. If not, then follow the steps:
cd your_working_directory
virtualenv environment_name where environment_name can be any name you want.
environment_name/Scripts/activate if on Windows
Or environment_name/bin/activate if on MacOS
Then after activating the environment you can install all the dependencies using pip. i.e pip install django or pip install SpeechRecognition

Python module shows up in pip freeze, but cannot be imported

I'm in Win10 and use vanilla Python 3.7.3 (e.g. not conda or anything). I had a successful pip install for the package, the package shows up in pip freeze, and the package is supposed to be compatible with my version of Python. I've seen several threads with similar issues on OS X and Linux, and have tried to emulate their solutions on Windows, but no luck. I'm guessing it could be an issue with my PATH variable, but I'm not quite sure. The error I get when trying to import is the "No module named" error.
Went into site-packages...for some reason the module was named Bio there (everywhere else it's named biopython, again, including pip freeze) and importing that worked. Not sure if this was just a bad dev choice or what.

Import pip3 results in "ImportError: No module named 'pip3'

I am on Windows 7 with Python 3.5 installed on it.
Below is what happens:
import pip # works as expected
import pip3 # results in below error
ImportError: No module named 'pip3'
I have pip and pip3.exe both sitting in the same scripts folder.
I have scripts folder, site packages and python folder all added to my environment variable path (I have added it in user profile, as I do not have admin access to add to system variables)
Is there any solution which you all have tried and worked. I am new to python and any help is appreciated.
So, I learned that my problem with installing beautifulsoup was because of the firewall restriction in my organization, which I was relating to pip install.
I learned of the proxy settings and using that, got to install bs4 via the conda interpreter.
Thank you for all the answers, which made me think through on various aspects, which I would not have thought of without the probing questions brought up here.

Cannot import module after installed by pip

I have already installed my wanted module from pip by using pip install but when i open up a program in idle and put import menu it says module not found what did i do wrong, im using python 3.7 and have the latest version of pip.
Python looks for its modules and packages in $PYTHONPATH. You'll need to figure out if the __init__.py module of the package you'd like to use is in python's path. To find out whether it is in python's path, run:
import sys
print(sys.path)
within python.
To add the path to your module, run:
sys.path.append("/path/to/your/package_or_module")
and you should be set.
I met the same problem, but in my case the package is created by myself. So this answer applyes to the custom packages. See Why customer python package can not be imported? for details.
Just in case someone is meeting a similar problem to mine.
Pay attention to the case of the package. In my case, the package is called 'shapely'. And I installed it through
pip install Shapely
But you have to import as
import shapely

Categories

Resources