install flask-pymongo with pip- python 3.6 - python-3.x

hellow everyone,
i tried to install PyMongo package with pip( i hope that is the way to do it). [its a part of a login system]
my command line was:
C:/Python36/Scripts/pip install PyMongo
But, when i put it in the command line i got
the system cannot find the file specificied.
And the import line in the code was:
from flask_pymongo import PyMongo
Do someone knows what should i do?
Thanks!!

Flask-PyMongo is a different package than PyMongo. It looks like you've only installed PyMongo, but are trying to use Flask-PyMongo in your application. You should run C:/Python36/Scripts/pip install Flask-PyMongo to install Flask-PyMongo.

You installed PyMongo and tried to import PyMongo from flask_pymongo.
PyMongo is a package to work with MongoDB. To make this work more efficient, Flask just made an extension named "Flask-PyMongo". So, we can directly import "Flask-PyMongo" and start working with MongoDB in a very efficient way.
You can think "Flask-PyMongo" as a wrapper of "PyMongo".

Related

How do I import a python package which is saved locally from a Git pull

Beginner here so I'm not even sure if this even close to best practise.
I've pulled a copy of a python package from Git, specifically https://github.com/slundberg/shap.git.
The result is saved where all my other Python packages are, I've called it shap_mv. Question is, if I make some changes to shap_mv and want to test the overall result, how do I import it as a package into Python?
Currently importing shap_mv works but the package has no contents. There is a subfolder with init.py and when I try import that folder as a package it seems to be missing functions and fails on import.
If I'm grossly far away from best practise then how should I work on the package and test the results?
Thank you!
Suppose the path of __init__.py is C:\\foo\\shap\\bar\\__init__.py and you want to import baz at C:\\foo\\shap\\bar\\baz.py.
import sys
sys.path.append('C:\\foo\\shap\\bar\\')
import baz
baz.somemethod()
The best practice is to use virtualenv and pip:
pip install shap
or
pip install "git+https://github.com/slundberg/shap.git#egg=shap"
or
git clone https://github.com/slundberg/shap.git
pip install shap
I solved this by putting an empty __init__.py. file in the shap_mv folder then running import shap_mv.shap as shap from python
This post helped:
importing a module in nested packages

ModuleNotFoundError: No module named pickle for py3.7

I am receiving this error from command prompt: ModuleNotFoundError: No module named 'pickle' running in python 3.7,
I have it setup like this:
import pickle as thisPickle
What can be the reason why I having this import issue, appreciate any help. Thanks.
pickle is a part of the Standard Library and is pre-included in the Python package. There should not be a reason that it does not work. Make sure that no other versions of python exist on your computer. The command prompt may be using outdated versions that still exist. Also, see if other modules install correctly on your machine.

"How to fix' ImportError: cannot import name 'SQLAlchemy'

import os
from flask import Flask
from flask_wtf import FlaskForm
import sqlalchemy
from flask_sqlalchemy import SQLAlchemy
bsdir = os.path.abspath(os.path.dirname(__file__))
# print(bsdir)
app = Flask(__name__, template_folder = 'template')
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+os.path.join(bsdir,'data.sqlite')
app.config['SQLALCHEMY_TRACK_MODIFICATION'] = False
db = SQLAlchemy(app)
class Puppy(db.Model):
pass
Traceback (most recent call last):
File "D:\PYTHON\GIT_EXC\FLASK_\flask_sqlalchemyex.py", line 5, in
from flask_sqlalchemy import SQLAlchemy File "D:\PYTHON\GIT_EXC\FLASK_\flask_sqlalchemy.py", line 4, in
from flask_sqlalchemy import SQLAlchemy ImportError: cannot import name 'SQLAlch
Try using this command
pip install flask-sqlalchemy --user
It worked for me
And If you are using PyCharm go to file
Select Invalidate caches and restart
Try to install it with these commands , (it worked for me):
pip install flask-sqlalchemy
pip3 install flask-sqlalchemy
Refer this site for Example
or
Refer the official guide site for installation
if it doesnt worked then try above commands with --user at the end of both commands
another solution maybe to install an IDE (if you are not using one) like PyCharm ; rather than a some simple text editors
First command installs package to python v2.x
Second one installs package to python 3.x
If you want to use 3.x to run your app ;then go to configuration and change it to python 3.x
Refer this for Getting Help / Development / Bug reporting
Try changing the name of your .py file. It may be causing a conflict with the flask-sqlalchemy package.
"D:\PYTHON\GIT_EXC\FLASK_\flask_sqlalchemy.py"
I faced same issue while instantiating airflow db by command
$airflow db init
error: ImportError: cannot import name 'SQLAlchemyAutoSchema'
Fixes:
Uninstall:
$pip uninstall marshmallow-sqlalchemy
Then upgrade it to version 0.24.0
$pip3 install marshmallow-sqlalchemy==0.24.0
My problem resolved and able to initialize airflow db.

How to import Python package (Pytorch-neat) that is not installable from pip/conda repositories?

I am trying to used Pytorch-neat package https://github.com/uber-research/PyTorch-NEAT but I don't understand the workflow of using it. I already installed python-neat package and I can import it using import neat in my Jupyter notebook. But what should I do with Pytroch-neat code? There is no pytorch-neat package in Conda or pip repositories, so, I guess that this Pytroch-neat code is not compiled and distributed as the Python package for Jupyter notebook. But what should I do with this code? E.g. sample script contains the code:
import neat
from pytorch_neat.multi_env_eval import MultiEnvEvaluator
So - neat is package and I am importing it. But how to understand the from clause? Should I load Pytroch-neat scripts somehow in the previous cells of my notebook and then I can call this from clause? Or maybe I should compile Pytroch-neat package locally and install it from local repository and import it similarly to neat package. But if so, why the examples use from clause?
I am starting to use Python and I am greatly confused with all of this!
To import from pytorch_neat you have to clone the repository and manually copy directory pytorch_neat into your site-packages (or any directory in sys.path).

How to solve this ModuleNotFoundError: No module named '_sqlite3' in docker-debian

While trying to run scrapy spider in docker-debian every time I get an error:
File "/usr/local/lib/python3.6/site-packages/scrapy/crawler.py", line 82, in
crawl
yield self.engine.open_spider(self.spider, start_requests)
builtins.ModuleNotFoundError: No module named '_sqlite3'
python version 3.6.3
scrapy 1.6.0
tried instruction from this post - ImportError: No module named '_sqlite3' in python3.3
still see this error.
when type sqlite3 command in terminal it shows sqlite3 version and start sqlite terminal.
SQLite version 3.16.2 2017-01-06
when type python and write next command in terminal:
import sqlite3
get this error:
ModuleNotFoundError: No module named '_sqlite3'
is there any way to solve this problem? looks like there is some misconfiguration but I can't find where it's
I have the same error with sqlite3 while I was trying to start my crawler using scrapy crawl my-crawler, after some searches and tried out different solutions, I found this answer useful to my error. Just remember that you need to download your specific python version, mine was 3.8.1 and it worked thanks to their answer. I have already install sqlite3 using sudo apt install libsqlite3-dev. Hope it works in your case, too. So, at first install it then reconfigure your python via instructions in the link.
I had same problem in centos, I just fix it. I install multiple python version in pyenv, so I switch the python version from 3.6 to 3.4.1, then problem solved.Maybe the problem was caused by pyenv,or it's python version's problem. If you don't have pyenv,maybe you need to reinstall python,or install a diffrent version of python.Hope be helpful.

Resources