Behave - command not found in Mac OS - python

When trying to run behave in the Mac terminal, a command not found error is raised, even tho I've installed behave using pip3:
user_name features % pip3 install -U behave
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: behave in /Users/gamunteanu/Library/Python/3.9/lib/python/site-packages (1.2.6)
Requirement already satisfied: six>=1.11 in /Users/gamunteanu/Library/Python/3.9/lib/python/site-packages (from behave) (1.16.0)
Requirement already satisfied: parse-type>=0.4.2 in /Users/gamunteanu/Library/Python/3.9/lib/python/site-packages (from behave) (0.5.2)
Requirement already satisfied: parse>=1.8.2 in /Users/gamunteanu/Library/Python/3.9/lib/python/site-packages (from behave) (1.19.0)
Any ideas? Can't seem to figure it out

Related

ModuleNotFoundError: No module named 'flask_cors' on python anywhere

To state from the get go this is no criticism of pythonanywhere, but I want to run a script that used to work using the line:
from flask_cors import CORS
But I get the following error mesage:
ModuleNotFoundError: No module named 'flask_cors'
Then tried to install in my version of python:
pip3.9 install Flask-Cors
The result was:
Defaulting to user installation because normal site-packages is not
writeable Looking in links: /usr/share/pip-wheels Requirement already
satisfied: Flask-Cors in ./.local/lib/python3.9/site-packages (3.0.10)
Requirement already satisfied: Six in
/usr/local/lib/python3.9/site-packages (from Flask-Cors) (1.16.0)
Requirement already satisfied: Flask>=0.9 in
/usr/local/lib/python3.9/site-packages (from Flask-Cors) (2.0.0)
Requirement already satisfied: Werkzeug>=2.0 in
/usr/local/lib/python3.9/site-packages (from Flask>=0.9->Flask-Cors)
(2.0.1) Requirement already satisfied: itsdangerous>=2.0 in
/usr/local/lib/python3.9/site-packages (from Flask>=0.9->Flask-Cors)
(2.0.1 ) Requirement already satisfied: click>=7.1.2 in
/usr/local/lib/python3.9/site-packages (from Flask>=0.9->Flask-Cors)
(7.1.2) Requirement already satisfied: Jinja2>=3.0 in
/usr/local/lib/python3.9/site-packages (from Flask>=0.9->Flask-Cors)
(3.0.1) Requirement already satisfied: MarkupSafe>=2.0 in
/usr/local/lib/python3.9/site-packages (from
Jinja2>=3.0->Flask>=0.9->Flask-C ors) (2.0.1) 15:33 ~$ pip show
Flask-Cors
Name: Flask-Cors Version: 3.0.10 Summary: A Flask extension adding a decorator for CORS support Home-page:
https://github.com/corydolphin/flask-cors Author: Cory Dolphin
Author-email: corydolphin#gmail.com License: MIT Location:
/home/elksie5000/.local/lib/python3.9/site-packages Requires: Six,
Flask
What gives and how do I fix it?
I think you should try the following:
Go to your Bash Console in "Consoles" menu.
Open the bash control
Select your virtualenv:
For example my virtualenv name is flaskapp, I would wirte "workon
flaskapp" in the bash console.
Now type in your desired command
pip3.9 install flask-cors in your case (try in lower case)
Make sure you are working in the same virtualenv and the same python version
(I think you want to make an API using cors maybe)

what is the best way to solve some Python packages that could not installed by conda

Recently I am facing a embrassing problem is that some Python packages must install using pip. I have read the pip and conda difference:
What is the difference between pip and conda?
I think many people facing the same problem that when you choose conda, then some package could not using conda install, when you use pip install the pacakge, it could not imported into the local project because the project only could import pakcage installed by conda install command. For example I want to use eyeD3 to read the mp3 meta data, but the package could not installed by conda, I installed the package using pip but could not import in the PyCharm IDE. What is the best way to solve this conflict? Am I missing something? Or I have to switch to pip? is it possible to make conda could install package from pip? Any suggestion is welcome, I want to fetch a guidline. I have tried install package like this in the macOS Big Sur:
/usr/local/anaconda3/envs/pydolphin ⌚ 22:20:21
$ ./bin/python -m pip install eyed3 ‹ruby-2.7.2›
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: eyed3 in ./lib/python3.9/site-packages (0.9.6)
Requirement already satisfied: filetype<2.0.0,>=1.0.7 in ./lib/python3.9/site-packages (from eyed3) (1.0.8)
Requirement already satisfied: coverage[toml]<6.0.0,>=5.3.1 in ./lib/python3.9/site-packages (from eyed3) (5.5)
Requirement already satisfied: deprecation<3.0.0,>=2.1.0 in ./lib/python3.9/site-packages (from eyed3) (2.1.0)
Requirement already satisfied: toml in ./lib/python3.9/site-packages (from coverage[toml]<6.0.0,>=5.3.1->eyed3) (0.10.2)
Requirement already satisfied: packaging in ./lib/python3.9/site-packages (from deprecation<3.0.0,>=2.1.0->eyed3) (21.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./lib/python3.9/site-packages (from packaging->deprecation<3.0.0,>=2.1.0->eyed3) (3.0.6)
(base)
still could not import this pakacage in the PyCharm IDE. I could found the package from the env:
/usr/local/anaconda3/envs/pydolphin/lib/python3.9/site-packages/eyed3

ModuleNotFoundError on virtual env Jupyter lab

I have created a virtual env and installed Jupyter notebood and jupyter lab
after import pandas I get ModuleNotFoundError: No module named 'pandas'
doing the same operation with jupyter notebook does not give me an error, which run in the same venv
I installed pandas into the venv, but got the same error
importing the native python modules works fine
inserting !pip install pandas in an empty cell above returns
Requirement already satisfied: pandas in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (1.1.3)
Requirement already satisfied: pytz>=2017.2 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (2020.1)
Requirement already satisfied: python-dateutil>=2.7.3 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (2.8.1)
Requirement already satisfied: numpy>=1.15.4 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from pandas) (1.19.2)
Requirement already satisfied: six>=1.5 in /home/curwin/jupyterlab/venv/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas) (1.14.0)
I have install a kernel inside the venv with
ipython kernel install --user --name=.venv
and running notebooks from this kernel solved the problem

pipenv is installed, but $ pipenv --version shows as command not found

Newbie here not understanding how pipenv can simultaneously show as installed and not installed at the same time. Am using Windows 10 (2004) in the VS Code terminal:
$ pip install pipenv returns this:
Requirement already satisfied: pipenv in c:\users\billa\appdata\roaming\python\python37\site-packages (2018.11.26)
Requirement already satisfied: virtualenv-clone>=0.2.5 in c:\users\billa\appdata\roaming\python\python37\site-packages (from pipenv) (0.5.3)
Requirement already satisfied: certifi in c:\users\billa\appdata\local\programs\python\python37\lib\site-packages (from pipenv) (2019.6.16)
Requirement already satisfied: virtualenv in c:\users\billa\appdata\local\programs\python\python37\lib\site-packages (from pipenv) (16.7.7)
Requirement already satisfied: setuptools>=36.2.1 in c:\users\billa\appdata\local\programs\python\python37\lib\site-packages (from pipenv) (44.0.0)
Requirement already satisfied: pip>=9.0.1 in c:\users\billa\appdata\local\programs\python\python37\lib\site-packages (from pipenv) (20.1.1)
But:
$ pipenv --version
Returns this:
$ pipenv: command not found
Perplexingly, if I use Ubuntu in Windows terminal, it reports back properly:
$ pipenv, version 2020.6.2
Thanks in advance.

Importing matplotlib gives error even though installed

I was hoping someone could help me out.
System is MacOS Catalina.
Python 3.8
IDE: VS
I installed matplotlib using pip install matplotlib which I saw stuck in under python2.7. I uninstalled matplotlib and reinstalled it using pip3 install matplotlib and received the following message:
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: numpy>=1.11 in /usr/local/lib/python3.7/site-packages (from matplotlib) (1.18.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/site-packages (from matplotlib) (2.4.6)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: six in /Users/apple/Library/Python/3.7/lib/python/site-packages (from cycler>=0.10->matplotlib) (1.13.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (46.0.0)
However, when I try to run my .py file with 'import matplotlib' it gives this error:
import matplotlib as mpl
ModuleNotFoundError: No module named 'matplotlib'
I've tried searching different sources for the solution but I am now stuck.
You are mostly running your python script with the command python your_file.py, try running as python3 your_file.py in your terminal. pip3 installs packages under python3, not the default python2.
This is because I believe your mac terminal uses python 2.x by default, therefore the command python uses python 2.x version and python3 uses 3.x version that is available to execute the files. So if you want to install any packages under python 2.x you use pip as the command and to install packages under python 3.x you use pip3 as the command

Categories

Resources