Python Module not found, but it is installed? - python-3.x

I wanted to make an Instagram bot so I can automate my posts and whatever. My problem is, I get the following Error when I try importing the module/library named "instagrapi":
Exception has occurred: ModuleNotFoundError
No module named 'instagrapi'
File "C:\Users\Simon\Desktop\Py\bot.py", line 1, in <module>
from instagrapi import Client
the error is in line 1 of my code, which simply states "from instagrapi import Client"
Now to my question: I already installed instagrapi, but VSCode tells me I didn't. I installed Python 3.11 but it runs in 3.10 or what so ever.
If someone can help me, please do so, thanks in advance
I tried reinstalling the library and restarting vscode, but it didn't help.
I'm running out of ideas

Related

Why are these import errors occurring when running python scripts from cmd or windows task scheduler, but not anaconda?

I am encoutering import errors, but only when running my python scripts from cmd or windows task scheduler (effectively the same issue I assume). I have researched answers already and attempted various solutions (detailed below), but nothing has worked yet. I need to understand the problem in any case so that I can manage anything like it in the future.
Here is the issue:
Windows 10. Anaconda Python 3.9.7. Virtual enviromnent.
I have a script that works fine if I open an anaconda prompt, activate the virtual environment and run it.
However, this is where the fun starts. If I try to run the script from the non-anaconda cmd prompt deploying the commands: "C:\Users\user\anaconda3\envs\venv\python.exe" "C:\Users\user\scripts\script.py" if get the following error:
ImportError: DLL load failed while importing etree: The specified module could not be found.
Traceback includes:
"C:\Users\user\anaconda3\envs\venv\lib\site-packages\lxml\html\__init__.py", line 53, in <module>
from ..import etree
This is not as simple as one specific module not being installed, because of course running the script from within the anaconda prompt and the virtual environment works. Similar also happens when I run other scripts. Other errors I have seen include, for example:
ImportError: DLL load failed while importing _imaging: The specified module could not be found.
Traceback includes:
"C:\Users\user\anaconda3\envs\venv\lib\site-packages\PIL\Image.py", line 114, in <module>
from . import _imaging as core
Also, I think this may be somehow related. Importing numpy (1.22.3) from within the python interpreter in the virtual environment works fine, but when I try to run a test script that imports numpy it fails both from anaconda and the cmd with the following error:
ImportError: cannot import name SystemRandom
The oveall issue was noted originally when trying to run various scripts from Windows Task Scheduler with the path to python "C:\Users\user\anaconda3\envs\venv\python.exe" entered as the Program/script and the script "script.py" entered as an argument. The above errors were produced, then reproduced by running the scripts from a non-anaconda cmd.
I am looking to understand what is happening here and for a solution that can get the scripts running from the virtual enviroment from Windows Task Scheduler effectively.
Update:
I have uninstalled and reinstalled numpy (and pandas) using conda. This has left the venv with numpy==1.20.3 (and pandas=1.4.2). On attempting to re-run one of the scripts, it runs fine from within the venv in anaconda, but produces the following error when attempting to run from cmd or from within Windows Task Scheduler as above:
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions faled. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.
We have complied some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "C:\Users\user\anaconda3\envs\venv\python.exe"
* The NumPy version is "1.20.3"
and make sure that they are the versions you expect.
Please carefull study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
I have looked into the solutions suggested, but am still completely at a loss, especially as to why the script runs from the venv in one place, but NOT the other.

ModuleNotFoundError no module named onetimepad?

i have deployed my web app on pythonanywhere website and the website is working properly but i also created the virtualenv where i installed my app packages everything is working fine
but when i import the new packages in the file in my pyton file like import onetimepad as onetimepad
it gives me error given below
ModuleNotFoundError: no module name 'onetimepad'
How to get rid of from this error Any help would be appreciated thanks in Advance
finally i found out the solution my python version is 3.8
pip3.8 install onetimepad

Unable to use gitpython ImportError

Tried to run a script I wrote yesterday again today and ran into this:
ImportError: cannot import name 'Repo' from 'git' (/usr/local/lib/python3.7/site-packages/git/__init__.py)
I am at a complete loss. On a new computer so the only thing different install wise would have been that I installed pycharm. I am currently trying to run through bash shell on a mac. The exact code was running as excepted earlier, no code changes.
Things I have tried:
uninstalling/reinstalling python
uninstalling/reinstalling pip
uninstalling/reinstalling gitpython
Running on:
mac catalina
python version 3.7.6
pip version 20.0.1
As a side note, the script works as intended until the automated git push. Wondering if I should just make the os calls myself and not worry about this?
I really dont understand what I did/am doing wrong here.
EDIT:
Again, sorry as this is my first mac computer. I did a brew uninstall of python3 and reinstalled through the app store to 3.8.
ImportError: cannot import name 'is_cygwin_git' from partially initialized module 'git.util' (most likely due to a circular import) (/Library/Frameworks/Python.framework/
I know cygwin is for windows, but I figured I'd play along and trying a pip install pycygwin.
Install threw an error asking for cython, so I did another pip install and tried again. The pycygwin then complained gcc was missing so I did a brew install of gcc. With gcc installed and correctly on path, it still says it cant find it and exits with
build/cygwin/_cygwin.c:611:10: fatal error: 'sys/cygwin.h' file not found
#include <sys/cygwin.h>
^~~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
Thinking I might just try a different package manager? Currently, an attempt to rerun the script yeilds
ImportError: cannot import name 'Repo' from partially initialized module 'git' (most likely due to a circular import)
To which I investigated but I shouldn't have any overlapping dependancies.
On the script throwing the error I'm using:
import csv
import yaml
import os
from git import Repo
and on the wrapper I made and imported, I'm using:
import subprocess
import re
Will update if I get any further on this, would love some suggestions.
EDIT:
Importing using just import git works throws a different error, like the python is trying to get itself?
ImportError: cannot import name '<file name>' from '<file name>'
If I change the file name and try to run it, it comes backs with:
ImportError: cannot import name '<old file name>' from '<old file name>'
***FIXED****
Uninstall of python through homebrew
Reinstall of python through mac app store
Uninstall/Reinstall of modules through pip
Saving the file under a new name and deleting the old one
Still have absolutely no idea why/how this happened but the above worked for me. If anyone knows why something like this can happen, I would love to know. Cheers.

Illegal Instruction 4 (Made a mess of python installation, no idea what I'm doing)

I am inexperienced with bash, python, and simply a lot of the basics/fundamentals some might take knowledge of for granted. I am using macOS 10.7.5. After installing numpy but getting error messages when importing in IDLE, I decided to reinstall python 3.7, but am getting several error messages now.
Some time ago, I installed python 3.7 from the python website, and it worked just fine. However, I had a great deal of trouble installing packages. The final straw was when I "successfully" installed numpy, but then I got a string of error messages when trying to import it in IDLE. I decided to try to re-install python, so I deleted python 3.7 and re-installed the same version from the same place.
However, when I tried typing "python3" in the Terminal, I got: "Segmentation Fault: 11". I researched it and understood that it had to do something with memory, so I must have uninstalled/installed wrong. However, I tried typing "python3" again, and got "Illegal Instruction: 4". After several tries, this is the only message I get anymore, and the segmentation fault does not appear.
I have no idea what I'm doing, and I don't know where to start. All I really know is that I've made a mess of the situation. I realize the solution might appear obvious, but I am completely inexperienced and in the dark right now. Thank you for reading this, I hope I can learn from you.
(Please ask for any and all information you might need, as I also don't know what exactly you might want to know.)
EDIT:
I realized when I re-installed Python, I had installed the macOS 10.9+ version. I uninstalled it and installed the correct version (10.6+). IDLE works and so does pip, but now I am getting the original error when I try to import numpy.
This is what I get:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/__init__.py", line 148, in <module>
from . import fft
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/__init__.py", line 6, in <module>
from .fftpack import *
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack.py", line 44, in <module>
from . import fftpack_lite as fftpack
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack_lite.cpython-37m-darwin.so, 2): Symbol not found: ___sincos_stret
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack_lite.cpython-37m-darwin.so
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack_lite.cpython-37m-darwin.so```

python module not found error

This question has been asked a few times, but the remedy appears to complicated enough that I'm still searching for a user specific solution.
I recently installed Quandl module using pip command. Even after successful installation my python idle is still showing
Traceback (most recent call last):
File "F:\Python36\Machine Learning\01.py", line 3, in <module>
import Quandl
ModuleNotFoundError: No module named 'Quandl'
I have used import command in my code.
I am using python 3.6.1 version.
I am working on a windows 10 Desktop.
I have also tried re-installation of module.
You can better navigate to your python scripts folder and open a command window there and try pip3 install quandl .Hope this helps.

Resources