ModuleNotFoundError: No module named 'django_popup_view_field' - python

You see that all is installed, but when I run runserver I got this error :
ModuleNotFoundError: No module named 'django_popup_view_field'
[p-amc-dgps-er#192-168-150-254 Invest_App]$ sudo pip install
django-popup-view-field [sudo] Mot de passe de p-amc-dgps-er :
DEPRECATION: Python 2.7 will reach the end of its life on January 1st,
2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python
2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already satisfied: django-popup-view-field in
/usr/lib/python2.7/site-packages (0.5.0) Requirement already
satisfied: Django>=1.8 in /usr/lib/python2.7/site-packages (from
django-popup-view-field) (1.11.26) Requirement already satisfied: pytz
in /usr/lib/python2.7/site-packages (from
Django>=1.8->django-popup-view-field) (2018.9)

Maybe you should add this module to settings.py:
INSTALLED_APPS = [
...
'django_popup_view_field',
...
]

It won't let me comment because I don't have enough rep, but are you installing django-popup-view-field within a virtual environment? And are you also running runserver within that same virtual environment? it seems to be the most common issue when receiving the error "ModuleNotFound". Please look at this link it might help you.
If all else fails, sometimes it helps just to completely come out of that terminal and try again.

Related

Installing Packages on ATOM for python (linter and autopep8)

I am trying to set up my environment for ATOM for python. I did this on my previous PC and didn't run into much trouble but this time I believe something is messed up and I don't know how to fix it.
Linter-flake8 installation:
I installed it by doing this:
settings --> install --> search packages --> linter-flake8 --> install.
Dependencies were installed afterward automatically.
then I ran the CMD and installed flake8 using:
py -m pip install flake8
When I try typing my code into ATOM; I get this error:
[Linter] Error running Flake8 Error: Failed to spawn command `flake8`. Make sure `flake8` is installed and on your PATH
at C:\Users\yazan\.atom…\lib\helpers.js:130
(anonymous) # C:\Users\yazan\.atom…ter\dist\index.js:1
Things I tried to fix this:
Adding ATOM to my path, which I did but did not work (ATOM and
Python both are in my user and system, environment variables)
Checking that my ATOM is running the same version of python.
import sys
print(sys.version)
3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
Checked installation path for my linter-flake8 in CMD:
result -->
C:\Users\yazan>py -m pip install flake8
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: flake8 in c:\users\yazan\appdata\roaming\python\python39\site-packages (3.9.2)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in
c:\users\yazan\appdata\roaming\python\python39\site-packages (from flake8) (0.6.1)
Requirement already satisfied: pyflakes<2.4.0,>=2.3.0 in
c:\users\yazan\appdata\roaming\python\python39\site-packages (from flake8) (2.3.1)
Requirement already satisfied: pycodestyle<2.8.0,>=2.7.0 in
c:\users\yazan\appdata\roaming\python\python39\site-packages (from flake8) (2.7.0)
I am running out of ideas and searched a lot but could not figure out how to fix this.
Thanks!
As mentioned in the linter-flake8 README, you can set the executablePath in the package settings. This should help you get around Atom's flaky support for environment variables.

ImportError: "flask_sqlalchemy" could not be resolved

i'm unable to import flask_sqlalchemy even after installing flask-sqlachemy
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
# ^this line shows error ImportError: "flask_sqlalchemy" could not be resolved
app = Flask(__name__)
#app.route('/')
def index():
return render_template('index.html')
i'm not using any virtual environment and flask-sqlalchemy shows already installed
(base) sachin#sachin:~/Coding/flask/blog$ pip install Flask-SQLAlchemy
Requirement already satisfied: Flask-SQLAlchemy in /home/sachin/anaconda3/lib/python3.8/site-packages (2.4.4)
Requirement already satisfied: SQLAlchemy>=0.8.0 in /home/sachin/anaconda3/lib/python3.8/site-packages (from Flask-SQLAlchemy) (1.3.20)
Requirement already satisfied: Flask>=0.10 in /home/sachin/anaconda3/lib/python3.8/site-packages (from Flask-SQLAlchemy) (1.1.2)
Requirement already satisfied: Jinja2>=2.10.1 in /home/sachin/anaconda3/lib/python3.8/site-packages (from Flask>=0.10->Flask-SQLAlchemy) (2.11.2)
Requirement already satisfied: itsdangerous>=0.24 in /home/sachin/anaconda3/lib/python3.8/site-packages (from Flask>=0.10->Flask-SQLAlchemy) (1.1.0)
Requirement already satisfied: click>=5.1 in /home/sachin/anaconda3/lib/python3.8/site-packages (from Flask>=0.10->Flask-SQLAlchemy) (7.1.2)
Requirement already satisfied: Werkzeug>=0.15 in /home/sachin/anaconda3/lib/python3.8/site-packages (from Flask>=0.10->Flask-SQLAlchemy) (1.0.1)
Requirement already satisfied: MarkupSafe>=0.23 in /home/sachin/anaconda3/lib/python3.8/site-packages (from Jinja2>=2.10.1->Flask>=0.10->Flask-SQLAlchemy) (1.1.1)
pip freeze shows me its already installed -
Flask==1.1.2
Flask-SQLAlchemy==2.4.4
I had the same error. Changed my system python by doing the following in VS Code:
Under the view menu select 'show command pallet'. One of the commands you can then select from the command palette is 'Python: Select Interpreter'.
Selecting this option will allow you to choose which version of python to use.
This post is pretty old but I found a different solution that might help others out. For me, the issue was my IDE/Python (venv). I am using Visual Studio ver. 1.57.1 as of now on Windows 10.
Open Visual Code.
Go to 'View' on the toolbar.
Click on 'Command Palette...' (or press CTRL + SHIFT + P on Windows).
Search for: 'Python Select Interpreter'.
Click on: 'Enter interpreter path...' followed by 'Find...'.
Go to your (venv) scripts folder: project_folder/venv/Scripts.
Select python.exe or pythonw.exe inside of your project_folder/venv/Scripts folder.
That's all.
The Flask-SQLAlchemy was installed in my virtual environment (venv). But my VSCode was using the system/PC Python interpreter to find the packages instead of the venv.
Hope this helps someone else out.
I had the same issue, this worked for me:
In cmd, cd to your project folder, (for me i had to activate venv, so it showed (env) C:\ etc\etc>)
Then install it here with:
pip3 install flask-SQLAlchemy
for some reason this took this noob 12 tries, but the give away was there was no sqla files in my site folder, and it kept showing the install had taken place in my python39 folder.
This is for people who do not use Anaconda (I had this issue and I solved it this way)
Your venv might be incorrect. Did you copy paste your venv from another directory?
venv saves path information, so when you run env\Scripts\activate, the venv believes it is in a different directory.
It will install the packages in the OLD directory. Make sure you generate a new py -m venv env for every app you create rather than copy pasting.
The solution is to delete your current venv directory, and run the py -m venv env command again. Then the packages will be installed in the current venv.
Had the same issue, resolved using:
activate the venv
use pip3 to install flask and flask_sqlalchemy by running:
pip3 install flask_sqlalchemy flask
And lastly checking if correct python interpreter was selected in vscode from:
CMD + Shift + P --> Python: Select Interpreter --> selecting appropriate python version for the venv (preferably python10)
I had the same problem, but it worked when I changed to Python Interpreter under the command palette of the view tab. If you believe you have installed all required packages and it does not work then definitely try this.
One thing I have noticed is that if I change the python interpreter from command palette(ctrl+shift+p) to my virtual environment one it does not work. First I tried the command,
py -3 -m pip install flask-SQLALchemy
Instead of the above command, I upgrade pip by using,
python -m pip install --upgrade pip
then I tried using the following to import SQLAlchemy.
python -m pip install flask-SQLALchemy
and it worked for me.
When you have done changes, I mean change your python interpreter, delete your env or re-create install packages again. Please close your app.py file and re-open it. Some times it still gives your error.
For anyone looking for a more recent answer. I couldn't find a scripts folder. On my ubuntu machine I did this (in vscode):
ctrl + shft + p
search select python interpreter
enter interpreter path
navigate to your-app/venv/python3
select python3
This resolved the import issue.

Is my python environment broken? Unable to install gastrodon using PIP

Using Python 3.8 on Windows, having installed a number of other modules I have tried to install gastrodon with
(property) C:\Users\andyt>pip install gastrodon
The result is this:
Requirement already satisfied: gastrodon in c:\users\andyt\anaconda3\envs\property\lib\site-packages (0.9.3)
Requirement already satisfied: pandas in c:\users\andyt\anaconda3\envs\property\lib\site-packages (from gastrodon) (1.0.3)
Requirement already satisfied: IPython in c:\users\andyt\anaconda3\envs\property\lib\site-packages (from gastrodon) (7.13.0)
WARNING: No metadata found in c:\users\andyt\anaconda3\envs\property\lib\site-packages
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\andyt\\anaconda3\\envs\\property\\lib\\site-packages\\ipython-7.13.0.dist-info\\METADATA'
Does anyone know how to fix this? I am able to install it in base...
Have you tried turning it on and off again? I mean potentially uninstall and reinstall it. I had a similar problem downloading numpy a while back and that seemed to fix it.
so I renamed metadata.json to metadata in a few similar positions where the install failed sequentially, and it appeared to have been successful, except I am now dealing with another error when trying to import gastrodon...

Using Python Script in Power BI, ImportError: Missing required dependencies ['numpy']

I am pretty new in Power BI and I try to set up the python script in it.
I have changed the option and activated the Python scripting. After that I get the error:
DataSource.Error: ADO.NET: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib.pyplot
File "C:\Users\mm\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
Details:
DataSourceKind=Python
I check the conda list and it contains numpy.
I have installed numpy and pandas again and I got the message below
C:\Users\mm\AppData\Local\Continuum\anaconda3>py -m pip install numpy
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: numpy in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (1.15.4)
C:\Users\mm\AppData\Local\Continuum\anaconda3>py -m pip install pandas
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: pandas in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (0.23.4)
Requirement already satisfied: python-dateutil>=2.5.0 in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from pandas) (2.7.5)
Requirement already satisfied: pytz>=2011k in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from pandas) (2018.7)
Requirement already satisfied: numpy>=1.9.0 in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from pandas) (1.15.4)
Requirement already satisfied: six>=1.5 in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)
As you see I am using anaconda3 but there is another Python is installed on my macheine. I tried a lot of ways and nothing could help
Open the Anaconda Prompt:
Then, you have to go to the Conda Environment that you want to use in PowerBI. Am having an environment 'temp', so I activate it first in the 'Anaconda Prompt':
(base) C:\Users\ashish>conda activate temp
Then I go to the directory having the "PowerBI" executable file in the installation folder:
(temp) C:\Users\ashish>cd "C:\Program Files\Microsoft Power BI Desktop\bin"
Then, I launch PowerBI from the Prompt:
(temp) C:\Program Files\Microsoft Power BI Desktop\bin>PBIDesktop.exe
This fixes the NumPy error you are getting. If you want any other package to use with PowerBI, install that package in the respective "Conda Environment" (in my case it is "temp").
forget Anaconda and use WinPython.
I tried Anaconda for days with all the workarounds available in StackOverflow and other forums, and they took me nowhere.
Then I tried WinPython, and it worked immediately. Of course, you will need to change the PowerBI options accordingly.
To install WinPython: https://github.com/winpython/winpython
To change the detected Python home directory: https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts#enable-python-scripting
If you consider my answer above others, you won't need to downgrade Python, PBI, or anything else.
I had similar issue trying to get Power BI to use Anaconda Python. After seeing a post about PBI having issues with Python 3.7 I:
Created a new environment in Anaconda using the Anaconda Navigator and made sure the new environment were using Python 3.6 (so NOT 3.7).
Installed in that environment the packages such as Pandas, Matplotlib and Seaborn that were used in my Power BI Python script
Went to Power BI's settings: File/Options and Settings/Options/Python scripting and set "Other" for Detected Python home dir and instead navigated to my new 3.6 python environment directory (visable in Anaconda Navigator at the bottom of the screen when selecting that environment)
..and that worked fine.
I think this error can be due to some numpy issues with Anaconda distribution.
I changed the Python path in Power BI to a virtual environment (which uses pip instead of conda to install numpy and other packages) and I had no more issues.

Python Module Not found error (Requests)

I am relatively new to Python and I was installing a couple of modules - BeautifulSoup and Requests (learning how to scrape). So I installed Requests
$ pip install requests
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (2.19.1)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from requests) (2018.4.16)
Requirement already satisfied: idna<2.8,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from requests) (2.7)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from requests) (1.23)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from requests) (3.0.4)
But then I when I run my file, I keep getting this error message
$ python test5.py
Traceback (most recent call last):
File "test5.py", line 1, in <module>
import requests
Could you help me with why I am having this issue?
On a separate note, all of a sudden BBEdit started asking me when I save a .py file "BBEDIT is trying to install a helper tool" and asking for a PW. Then it asks again "BBEDIT is trying to make modifications, allow it"? WHy is it doing that? Is it safe?
Thanks everyone and sorry for basic questions
A Stack Overflow answer can only cover one specific answer, not give a complete tutorial. But you probably actually want a complete tutorial. Also, if you're reading this from the distant future, whatever is written below may be as out-of-date as laptops that only do video and sound without smellovision. So, you should read the Python Packaging Authority's tutorial on installing packages.
You have (at least) two Python installations:
A Python 3.6 that you probably installed with a python.org installer, which lives in /Library/Frameworks/Python.framework/Versions/3.6/.
A Python 2.7 that Apple included as part of the OS, which lives in /System/Library/Frameworks/Python.framework/Versions/2.7/.
If you just run python, you get the Apple 2.7, not your 3.6. But you installed your packages for your Python 3.6, not your 2.7.1 (Plus, you don't want to run 2.7 anyway.)
You're supposed to run python3, as explained in PEP 394—or, better, use a virtual environment—when you have both Python 2.x and Python 3.x on the same system.2
Either will solve your problem.
If you're curious why pip installed for 3.6 instead of 2.7… well, it shouldn't work that way. But Apple's Python 2.7 is a bit out of date (I mean, even out of date for 2.7), so it doesn't even include pip. Which means the only pip on your system is the 3.6 one. So, even though python runs python2.7 instead of python3.6, pip runs pip3.6 instead of pip2.7. Which is very confusing, and pretty much unavoidable on current Macs.
This is a part of the reason current recommendations suggest never running pip directly; instead, run it like this:
python3 -m pip install requests
That guarantees that the Python installation you're installing requests into is the same on that you get when you run your script with python3 test5.py.
As things currently stand, as long as you don't ever touch Apple's 2.7, you can get away with just using pip3, or even pip. But that could easily change in, say, macOS 10.14, so better to get into the right habit.
1. You can tell because of, e.g., the paths in those "Requirement already satisfied" lines.
2. Well, the same non-Windows system, but you don't want to learn the different ways in which Windows is messed up, just stick to macOS here…

Categories