Python imports aren't installing / can't be found - python

Firstly, I'm super new to Python/code and stackoverflow, so apologies if I sound like a child trying to explain complex rocket science.
I'm following a tutorial on creating a fake teachers database, and they say
import mysql.connector
from mysql.connector import Error
import panda
however, when I go to import, I get an error of
ImportError: Unable to import required dependencies:
pytz: No module named 'pytz'
dateutil: No module named 'dateutil'
Despite the modules being imported and in the Python folder. It took me around 30 minutes to get MySQL imported, and honestly I'm not even really sure how it fixed. I renamed the folder, I copied the folder into the virtual environment I'm using (which I'm not even sure how to not use that, it seems to just create difficulties in doing any importing), I had to reinstall pip multiple times as it also error'd the first 2 tries. I'm really confused and a little frustrated as I have zero idea how to fix this, or what even the errors are in the first place.
Any help would be much appreciated!!

Pip should be included with your Python installation. Try pip install mysql and pip install panda. If that doesn't work try py -m pip install mysql and py -m pip install panda.

Try:
pip3 install mysql pytz
You can install multiple packages at the same time!

If you want to get out of the virtual environment you created you can use the deactivate command.

See If pip is installed in your system
If its Installed , Install pytz by exeuting
pip install pytz
Install Pip = https://bootstrap.pypa.io/get-pip.py
Just download and run this file

Related

how i can i solve no module named can error?

hello i'm using python 3 and ros noetic, and i got this error
import can
ImportError: No module named can
I've got this error before, and I solved it through a very simple can-bus related installation command in google. But I can't find that command now
I've tried all the like $ sudo apt install python3-can.
but I can't fix it at all
thank you................
The problem is, that the module can't be found by your python.
first, try to remove the package with:
pip uninstall python-can
and re-install it with
pip install python-can
In case you have several versions of python installed (such as python2 and python3) make sure, you use
pip3
instead of pip.
Next you can try to manually search your package directories for the package, if it is even there.
Try cloning the library with git and running the setup.py installation, worked for me.

Module installed but not found when import

I've got a documentation of the package named 'Google-Images-Search'
https://pypi.org/project/Google-Images-Search/
I've read and tyr to reproduce what's needed, so I installed it with this commandline :
pip install Google-Images-Search
Now when I'm trying to do it again, I've got the message like "Requirement already satisfying" for all dependencies and nothing append after.
So I've develop the file index.py with this inside
from google_images_search import GoogleImagesSearch
gis = GoogleImagesSearch('test1', 'test2')
But when I execute this, I've got
No module named Google_Images_Search
I already try to put in my code
help("modules")
But Google_Images_Search is not here at all
That more than 2 hours I'm on it, I've try to uninstall pip, pip3, use pip or pip3, reinstall, use python -m pip install ... But nothing work...
Please I don't understand, and I'm beginner with Python and a little with Raspberry and the Linux environment.
The documentation states that the name of the module that the project installs is google_images_search, all lowercase, not Google_Images_Search.
try changing your import,
from google_images_search import GoogleImagesSearch

No module named 'ffnet' in Python

I try a python code for signature recognition, and there is an import ffnet module (from ffnet import mlgraph, ffnet), but I got an error when I run it.
The error is:
ModuleNotFoundError: No module named 'ffnet'
I have install the module, but still got that error
Help me to fix this :)
You need to make sure that it is correctly installed. The error message means directly "You haven't installed it properly".
Depending on what Python version you're using, you should have a package manager called pip that takes charge of installing and uninstalling modules. Try:
pip2 install ffnet if you have Python 2.
pip3 install ffnet if you have Python 3.
Alternatively, you may have installed Python using Anaconda. In this case, use conda install ffnet. In all cases, run the proposed commands in a terminal.
However, it would be quite useful to have more details about your problem (what OS do you have, how and where did you install Python, what version do you have).
There is great chance that the pip (i suppose you use pip for installation, the idea is identical) you use to install ffnet is not correspond to the python you are using. Maybe a virtualenv is running, or you using python 2 but ffnet is installed with pip3
My suggestion:
- Run which pip. Run which python. Compare the results if anything seem wrong (python2 pip3 for example). Try to run python2 and pip2 instead of python and pip
- If the above suggestion doesn't work, you should try to recheck your PATH: Find the pip correspond to your current python (usually within the same dir) and export PATH=/path/to/THAT/pip/:$PATH
- If the problem still persist, I suppose your pip file's first line (for specifying its corresponding python path) has been modified without your awareness. You will have to manually edit it to something like #!/usr/bin/python3
Hope this help!

ImportError: No Module named picklefield.fields (Yep pip install says it is there)

I am using vagrant to run my python environment. In my data models I am using django-picklefield module.
when I run my server it says
ImportError: No module named picklefield.fields.
I tried to uninstall and install the picklefield module. Still having the same problem.
You should be able install via:
/[your python install directory]/bin/pip install django-picklefield
If you do this directly instead of a general pip call to install django-picklefield, that will ensure that it is installed on the correct version of Python.
Based on your description my best guess is that you have multiple versions of Python installed, and that your install/uninstall is happening on the wrong one.

Python cannot find dateutil.relativedelta

I am trying to run a program using paster serve, but I keep getting the error:
ImportError: No module named dateutil.relativedelta
I am running Python version 2.6.7 and dateutil version 1.5, so it should be installed.
Has anyone got any ideas as to why this would happen?
I am importing using
from dateutil.relativedelta import *
I can even see the package when I search:
/usr/lib/python2.7/site-packages/dateutil/relativedelta.pyc
/usr/lib/python2.7/site-packages/dateutil/relativedelta.py
/usr/lib/python2.7/site-packages/dateutil/relativedelta.pyo
UPDATE
Immediately I look at this and see that dateutil is only installed for Python 2.7, and I bet what I was doing was this:
sudo yum install python-dateutil
To which sudo would have switch to the default Python version (i.e., Python 2.7 instead of 2.6.4).
Solving this would have been as simple as:
su
(switch to virtual environment)
yum install python-dateutil
Using su and then switching to the virtual environment will give root access and install to the virtual Python directory. Using sudo will install libraries to the default directory, not the virtual environments site-packages.
I also ran into this issue. The simple solution I ended up using was to add --upgrade to the end of the command. This forced it to install it even though Python thought it was installed. This resolved the issue.
So if you have this issue, try the following:
sudo pip install python-dateutil --upgrade
It can't possibly hurt anything, so there is no harm in just forcing it to be reinstalled.
I had a similar issue but for a simpler reason. My fresh virtualenv simply didn't have dateutil installed and I didn't know the Python package name. I tried pip install dateutil, which obviously didn't work since the package name was incorrect. Running pip install python-dateutil instead worked (without resorting to sudo).
This looks like a problem of package installation to me. A troubleshooting list that comes to my mind:
Verify you installed the package.
If installed, verify that the files have been stored in the right directory (a directory accessible from your python interpreter (= in the PYTHONPATH, useful article here).
Verify permission on those files.
Restart your shell if you tried the import there.
Reboot your computer (ouch... it's 10 years since I started using GNU/Linux, but I still suffer from the bad memories of Windows! ;)
(The previous comment about installing python-dateutil helped me, so perhaps my comment helps someone else).
For those on Mac OS (v10.6 (Snow Leopard); I am not sure about other versions), the dateutils package is located by default at:
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/dateutil
whereas pip install writes the package out to:
/Library/Python/2.6/site-packages
and does not update the /Library/Python/2.6/site-packages/easy-install.pth file. As a result, when you import dateutil, you will still point to the old location, you can verify this by "import dateutil; dateutil.__file__".
So what I did (probably better methods are available) was to rename the old directory (/System/Library/.../dateutil) to dateutil.obsolete and restarted Python, then ran the same set of commands again. This doesn't do anything to the path file or sys.path, but skips the old dateutils package so you can get to the new one.

Categories

Resources