I have installed webkit-server and dryscrape - but when I run a script I get an error when using a dryscrape function. The error is as follows:
"No such file or directory: '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/webkit_server'"
However, when trying to install webkit_server, I get:
Requirement already satisfied: webkit_server in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (1.0)
To show I already installed it, see link image.
Suggestions from my side are:
There is a difference between webkit_server and webkit-server?
Webkit_server is in the wrong place and can't be found by dryscrape?
I tried to install both using gitclone - same error
Any suggestions would be useful.
List of pip3 installed packages includes webkit-server
Related
I am trying to import certain packages as I am working with Jupyter notebook files, and most of the packages seem to be missing, even though I have installed them. For example, when I do the command: from bs4 import BeautifulSoup or import requests
I get the error saying ModuleNotFoundError: No module named 'bs4' for the first one and a similar one for importing requests as well. I have tried pip install requests and pip install bs4, but same issue persists. I have installed them on:
"(base) aminnazemzadeh#amins-MacBook-Pro ~ % " which seems to be my home directory, and I also have anaconda3 installed alongside python3. What is the issue that I cannot import these modules.
I am using visual studio if it makes any difference
Once I add :
!pip install requests
!pip install bs4
I get:
/Users/aminnazemzadeh/.zshenv:.:1: no such file or directory: /Users/aminnazemzadeh/.cargo/env
Requirement already satisfied: requests in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (2.28.1)
Requirement already satisfied: charset-normalizer<3,>=2 in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (from requests) (2.0.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (from requests) (1.26.11)
Requirement already satisfied: idna<4,>=2.5 in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (from requests) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (from requests) (2022.9.24)
/Users/aminnazemzadeh/.zshenv:.:1: no such file or directory: /Users/aminnazemzadeh/.cargo/env
Requirement already satisfied: bs4 in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (from bs4) (4.11.1)
Requirement already satisfied: soupsieve>1.2 in /Users/aminnazemzadeh/opt/anaconda3/lib/python3.9/site-packages (from beautifulsoup4->bs4) (2.3.1)
followed by this warning:
ModuleNotFoundError Traceback (most recent call last)
Cell In[7], line 4
2 get_ipython().system('pip install bs4')
3 from urllib.request import urlopen
----> 4 from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
Thanks
probably you're installing the packages on an environment other than the one vs code is using. you can try installing the packages directly from your jupyter notebook by running the following code in a notebook cell. the current best practice to be running installs in the notebook is using the magic commands %pip or %conda:
%pip install requests beautifulsoup4
# or
%conda install requests beautifulsoup4
this should install the packages in the same environment that the notebook is running on.
note that you may need to restart the kernel to use the affected packages.
sources:
Jupyter Discourse Forum - Location of libraries or extensions installed in JupyterLab
Jupyter Discourse Forum - Why users can install modules from pip but not from conda?
Installing Beautiful Soup
ps: thanks #wayne for the comments regarding the current best practices for installing on the current running environment.
If you're using conda, you should install via conda whenever possible. When you install via pip, conda loses some of its ability to manage dependency versions.
Try creating a new conda environment, install the needed packages via conda, then set the kernel to your new environment in vscode. Dedicate conda environments to specific projects. It is okay to have a default/generic environment for playing around but not for any significant work as you can easily create errors in your other work if a dependency changes to an incompatible version.
Conda cheet sheet for reference if you need it: https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf
You will need the Jupyter extension in vscode if you do not already have it installed.
You will also need to install the corresponding jupyter package in your conda environment.
I am trying to connect to a database and for that I am using mysql-connector. The code is correct but I get the following error message:
ERROR: HTTP error 404 while getting https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz
If I use command window and type the following:
pip search mysql-connector
I get the error:
ERROR: XMLRPC request failed [code: -32500]
RuntimeError: PyPI's XMLRPC API is currently disabled due to unmanageable load and will be deprecated in the near future. See https://status.python.org/ for more information.
I have also already installed mysql-connector by using:
pip install mysql-connector-python
Requirement already satisfied: mysql-connector-python in c:\users\pf1vmkh9_adm\appdata\local\programs\python\python39\lib\site-packages (8.0.26)
Requirement already satisfied: protobuf>=3.0.0 in c:\users\pf1vmkh9_adm\appdata\local\programs\python\python39\lib\site-packages (from mysql-connector-python) (3.18.1)
So why do I get that error message?
A note: pip search not working is intended, as the error says - pip list/search was abused and was disabled. You should use PyPI manually to access information on packages - https://pypi.org/project/mysql-connector-python
As to your error... it tries to download mysql-connector-python-2.1.3.tar.gz, while your pip says Requirement already satisfied: mysql-connector-python in c:\users\pf1vmkh9_adm\appdata\local\programs\python\python39\lib\site-packages (8.0.26).
Look at the versions: 2.1.3 vs 8.0.26.
This means you either use wrong python version to run the project or something inside tries to use (and download) some really old code. Which is just no longer hosted at that url, hence you get 404 (not found).
I am building a python script that I want to compile to a .exe file for anyone to be able to run. I'm attempting to follow the guide on this other question, and I instantly ran into issues.
I'm currently developing on Windows 10 through the use of VSCode (I've also tried this through Pycharm to the same issue). I successfully have installed cx_Freeze to the point where when I try to install it again I get Requirement already satisfied:
PS E:\code\scorekeeper> py -m pip install cx_Freeze
Requirement already satisfied: cx_Freeze in c:\users\beau\appdata\local\programs\python\python39\lib\site-packages (6.8)
Requirement already satisfied: cx-logging>=3.0 in c:\users\beau\appdata\local\programs\python\python39\lib\site-packages (from cx_Freeze) (3.0)
Requirement already satisfied: importlib-metadata>=4.3.1 in c:\users\beau\appdata\local\programs\python\python39\lib\site-packages (from cx_Freeze) (4.8.1)
Requirement already satisfied: zipp>=0.5 in c:\users\beau\appdata\local\programs\python\python39\lib\site-packages (from importlib-metadata>=4.3.1->cx_Freeze) (3.5.1)
The issue is, the Pylance plugin I have in VSCode shows an error on the import saying that "Import "cx_Freeze" could not be resolved".
And as expected, when I try to run the script, I get this error:
PS E:\code\scorekeeper> & e:/code/scorekeeper/.venv/Scripts/python.exe e:/code/scorekeeper/setup.py
Traceback (most recent call last):
File "e:\code\scorekeeper\setup.py", line 1, in <module>
from cx_Freeze import setup, Executable
ModuleNotFoundError: No module named 'cx_Freeze'
Anyone have any ideas on what's going on here?
The problem was that I was not in an integrated terminal using the .venv file in the project, because windows had errored when it tried to set the .venv as the active terminal due to Execution policies. Once I gave the terminal permissions to run scripts and re ran the activate it was able to install the package.
It had installed the package to the python root PATH, but was using the interpreter in the .venv folder in the project.
I am working on a raspberry pi python project and every time I import a package I get the same error ModuleNotFoundError: No module named ''. for example I am trying to add the ambient_api package
I followed the steps in their set up:
pip install ambient_api
Added the imports at the top of my file:
from ambient_api.ambientapi import AmbientAPI
api = AmbientAPI()
but I am getting the error:
ModuleNotFoundError: No module named 'ambient_api'
This is happening with all the imports I am trying to add and I cant figure out what I am missing.
when I was looking on google I came across __init__.py might be a solution but I am not sure how this works?
edit:
here is what was output when I installed:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: ambient_api in /home/pi/.local/lib/python2.7/site-packages (1.5.2)
Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from ambient_api) (2.21.0)
Requirement already satisfied: urllib3 in /usr/lib/python2.7/dist-packages (from ambient_api) (1.24.1)
version in my terminal:
pi#raspberrypi:~/Raspberry-Pi-Greenhouse $ python --version
Python 2.7.16
but it looks like the version in the shell in the ide when I run the program is saying:
Python 3.7.3 (/usr/bin/python3)
As explained by #JaFizz in Pytorch is installed but do not working ubuntu 18.04 it solved by giving an alias and installing correctly to desired python version (there were two pythons installed on the same machine)
First it was necessary to specify the location of the python, example:
alias python=/usr/local/bin/python3.6
Then install it:
python pip install <package name>
I have been looking to implement the example Python scripts I have found online to allow me to interact with the YouTube API as per the GitHub link found here
The problem I am having is with the import statement at the start:
import argparse
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
The online documentation requires the following command to install the googleapiclient library:
pip install --upgrade google-api-python-client
However, once installed I am still receiving an error that googleapiclient.discovery cannot be found. I have tried reinstalling via pip, with the following command line output generated, suggesting all is well:
Requirement already up-to-date: google-api-python-client in g:\python27\lib\site-packages (1.7.4)
Requirement not upgraded as not directly required: httplib2<1dev,>=0.9.2 in g:\python27\lib\site-packages (from google-api-python-client) (0.9.2)
Requirement not upgraded as not directly required: google-auth>=1.4.1 in g:\python27\lib\site-packages (from google-api-python-client) (1.5.0)
Requirement not upgraded as not directly required: google-auth-httplib2>=0.0.3 in g:\python27\lib\site-packages (from google-api-python-client) (0.0.3)
Requirement not upgraded as not directly required: six<2dev,>=1.6.1 in g:\python27\lib\site-packages (from google-api-python-client) (1.10.0)
Requirement not upgraded as not directly required: uritemplate<4dev,>=3.0.0 in g:\python27\lib\site-packages (from google-api-python-client) (3.0.0)
Requirement not upgraded as not directly required: rsa>=3.1.4 in g:\python27\lib\site-packages (from google-auth>=1.4.1->google-api-python-client) (3.4.2)
Requirement not upgraded as not directly required: cachetools>=2.0.0 in g:\python27\lib\site-packages (from google-auth>=1.4.1->google-api-python-client) (2.1.0)
Requirement not upgraded as not directly required: pyasn1-modules>=0.2.1 in g:\python27\lib\site-packages (from google-auth>=1.4.1->google-api-python-client) (0.2.2)
Requirement not upgraded as not directly required: pyasn1>=0.1.3 in g:\python27\lib\site-packages (from rsa>=3.1.4->google-auth>=1.4.1->google-api-python-client) (0.1.9)
pyasn1-modules 0.2.2 has requirement pyasn1<0.5.0,>=0.4.1, but you'll have pyasn1 0.1.9 which is incompatible.
What am I doing wrong?
Thanks
In case you are running Python3 (python --version), perhaps you should run this instead:
pip3 install google-api-python-client
Another quick way to counter this problem could be to install the package in the same folder as your code:
pip install google-api-python-client -t ./
That's not ideal but it will definitely work.
Or if you prefer to move external libraries to a lib/ folder:
pip install google-api-python-client -t ./lib
in that last case you will also need this at the beginning of your Python code:
import os
import sys
file_path = os.path.dirname(__file__)
module_path = os.path.join(file_path, "lib")
sys.path.append(module_path)
from googleapiclient.discovery import build
This solution is only applicable to those using "Visual studio" for building flask apps.(others can try though)
The only thing you need to check is "from where am I importing all my libraries" follow the process below while creating new env.
Python environments >(Right click) > Add new env > check the "View in python environments window".
I faced similar issue while I was trying to write code involving 'YouTube API' in VS Code. On the suggestion by many folks from online coding forums I ran
pip install --upgrade google-api-python-client
but it didn't help.
Taking following steps resolved the issue for me:
In VSCode go to 'Settings' (Ctrl + , on Windows), inside 'Search settings' enter venv and under the heading for 'Python: Venv Path' enter the path for your virtual environment as seen in the following screenshot:
settings for Python: Venv Path in VS Code
And, then click on the Python interpreter in VS Code as seen below: (the selected interpreter reflects at the bottom left corner of the VS Code editor)
Python interpreter path