Jupyter Notebook cannot package folium - python

I tried to install a package folium into Jupyter Notebook. I had to try many methods, such as add system path, upgrade pip, install setuptools but I cannot make it. My laptop is Macbook Pro, system: Catalina 10.15.3, Jupyter Notebook from Anaconda. Python version: 3.7.4
System.exectutable:
'/opt/anaconda3/bin/python'
System path:
['/Users/scott/Documents/Untitled Folder',
'/opt/anaconda3/lib/python37.zip',
'/opt/anaconda3/lib/python3.7',
'/opt/anaconda3/lib/python3.7/lib-dynload',
'',
'/opt/anaconda3/lib/python3.7/site-packages',
'/opt/anaconda3/lib/python3.7/site-packages/aeosa',
'/opt/anaconda3/lib/python3.7/site-packages/IPython/extensions',
'/Users/scott/.ipython']
The code I wrote is:
import numpy as np
import pandas as pd
import collections
import re
import matplotlib.pyplot as plt
import matplotlib
from collections import OrderedDict
from math import ceil
#!python3 -m pip install folium --user
#!python3 -m pip install branca --user
#!python3 -m pip install jinja2 --user
#!python3 -m pip install requests --user
#!pip install --user scipy
#!python -m pip install --upgrade pip
import scipy
#import branca
! pip install --user folium
import tqdm
import folium
However, I got such error:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. 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
Collecting folium
Using cached folium-0.8.3-py2.py3-none-any.whl (87 kB)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from folium) (1.12.0)
Collecting jinja2
Using cached Jinja2-2.11.1-py2.py3-none-any.whl (126 kB)
Requirement already satisfied: numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from folium) (1.8.0rc1)
Collecting requests
Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting branca>=0.3.0
Using cached branca-0.4.0.tar.gz (41 kB)
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/setup.py'"'"'; __file__='"'"'/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/pip-egg-info
cwd: /private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/setup.py", line 41
print(error, file=sys.stderr) # noqa
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-201-2c07c456259d> in <module>
17 get_ipython().system(' pip install --user folium')
18 import tqdm
---> 19 import folium
ModuleNotFoundError: No module named 'folium'
I had confused with this error for days, could anyone help me? Thanks in advance!

Looks like you're trying to work in an anaconda 3.7 environment, but your error message is complaining about being python 2.7 and it's complaining it cannot find folium.
Did you somehow pip install the folium module while working outside your anaconda 3.7 environment?
Maybe you could try the conda navigator tool and grab the folium package that way...

Related

Troubles installing Matplotlib with pip (python 3.10 windows 11) [duplicate]

This question already has answers here:
Cannot install Matplotlib on Python 3.10
(2 answers)
Closed 1 year ago.
Im having a lot of difficulty installing matplotlib for python 3.10.0 on my new windows 11 machine. I will explain from the top down
In my VScode jupyter file I try to run the folowing code cell
import matplotlib
ModuleNotFoundError: No module named 'matplotlib'
I hop over to my cmd and run the folowing lines:
pip install --upgrade pip
Requirement already satisfied: pip in c:\users\robbe\appdata\local\programs\python\python310\lib\site-packages
pip install wheel
Requirement already satisfied: wheel in c:\users\robbe\appdata\local\programs\python\python310\lib\site-packages
pip install matplotlib
Collecting matplotlib
Using cached matplotlib-3.4.3.tar.gz (37.9 MB)
Preparing metadata (setup.py) ... done
all these requirements were satisfies
Building wheels for collected packages: matplotlib
Building wheel for matplotlib (setup.py) ... error
and now I get a huge error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\robbe\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\robbe\AppData\Local\Temp\pip-install-i7jkrq6p\matplotlib_45378a3fc28d4ce6bb53fd38cb01c06b\setup.py'"'"'; file='"'"'C:\Users\robbe\AppData\Local\Temp\pip-install-i7jkrq6p\matplotlib_45378a3fc28d4ce6bb53fd38cb01c06b\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\robbe\AppData\Local\Temp\pip-wheel-_bz0a7px'
cwd: C:\Users\robbe\AppData\Local\Temp\pip-install-i7jkrq6p\matplotlib_45378a3fc28d4ce6bb53fd38cb01c06b
Complete output (553 lines):
folowed by another error
ERROR: Failed building wheel for matplotlib
Running setup.py clean for matplotlib
Failed to build matplotlib
Installing collected packages: matplotlib
Running setup.py install for matplotlib ... error
Can someone help explain to me whats wrong here? I've tried almost every solution I could find on here (such as specifying a differet matplotlib build to install or running the line pip install --upgrade matplotlib) but I can't get it fixed
:( I just want to make some graphs
Sorry you guys, I've used this line
pip install matplotlib==3.5.0rc1
And this versions of matplotlib did work!!!! :)

yfinance - ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

I am trying to install yfinance "sudo -H pip install yfinance" and keep getting the following error at the bottom of this post. I have uninstalled/installed pip. I have uninstalled/installed setuptools via pip and have tried the following commands:
python3 -m ensurepip --upgrade
Requirement already up-to-date: setuptools in /usr/local/lib/python3.8/site-packages (49.2.0)
Requirement already up-to-date: pip in /usr/local/lib/python3.8/site-packages (20.1.1)
pip install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python3.8/site-packages (20.1.1)
pip install --upgrade setuptools
Requirement already up-to-date: setuptools in /usr/local/lib/python3.8/site-packages (49.2.0)
Python Version
python --version
Python 3.8.3
Pip Version
pip --version
pip 20.1.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
System Update Checks
sudo apt-get upgrade
sudo apt-get update
Actual error code below when I run "sudo -H pip install yfinance"
*****#*******:~/Desktop/Project$ sudo -H pip install yfinance
Collecting yfinance
Using cached yfinance-0.1.54.tar.gz (19 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xpuca0pe/yfinance/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xpuca0pe/yfinance/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1j4zanh6
cwd: /tmp/pip-install-xpuca0pe/yfinance/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 23, in <module>
from setuptools.dist import Distribution
File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How do I fix this error?
After running this command it fixed the error.
Reference: https://packaging.python.org/tutorials/installing-packages/
sudo -H python -m pip install --upgrade pip setuptools wheel

How to install PyVimeo for Python 3.7?

I'm trying to install PyVimeo for Python 3.7 in Windows.
I keep getting this error in my command terminal when trying a Pip install.
C:\Users\my_name\Downloads>C:/Users/my_name/Anaconda3/Scripts/pip install PyVimeo-1.0.11.tar.gz --user
Processing c:\users\my_name\downloads\pyvimeo-1.0.11.tar.gz
Requirement already satisfied: requests>=2.4.0 in c:\users\my_name\anaconda3\lib\site-packages (from PyVimeo==1.0.11) (2.24.0)
Collecting tuspy==0.2.1
Using cached tuspy-0.2.1.tar.gz (9.7 kB)
Requirement already satisfied: idna<3,>=2.5 in c:\users\my_name\anaconda3\lib\site-packages (from requests>=2.4.0->PyVimeo==1.0.11) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\my_name\anaconda3\lib\site-packages (from requests>=2.4.0->PyVimeo==1.0.11) (1.25.8)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\my_name\anaconda3\lib\site-packages (from requests>=2.4.0->PyVimeo==1.0.11) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\my_name\anaconda3\lib\site-packages (from requests>=2.4.0->PyVimeo==1.0.11) (2019.11.28)
Collecting pycurl==7.43.0
Using cached pycurl-7.43.0.tar.gz (182 kB)
ERROR: Command errored out with exit status 10:
command: 'C:\Users\my_name\Anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\my_name\\AppData\\Local\\Temp\\pip-install-ndtvvoaz\\pycurl\\setup.py'"'"'; __file__='"'"'C:\\Users\\my_name\\AppData\\Local\\Temp\\pip-install-ndtvvoaz\\pycurl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\my_name\AppData\Local\Temp\pip-install-ndtvvoaz\pycurl\pip-egg-info'
cwd: C:\Users\my_name\AppData\Local\Temp\pip-install-ndtvvoaz\pycurl\
Complete output (1 lines):
Please specify --curl-dir=/path/to/built/libcurl
----------------------------------------
ERROR: Command errored out with exit status 10: python setup.py egg_info Check the logs for full command output.
I've downloaded the PyVimeo file from here.
https://pypi.org/project/PyVimeo/
And went over various solutions from both StackOverFlow and github, but to no avail.
Any help in solving this is very much appreciated.
Possible solutions from github
https://github.com/vimeo/vimeo.py/issues/129
from StackoverFlow
Use PyVimeo from Anaconda
I've installed the latest version of setuptools.
UPDATE:
pip install PyVimeo --no-dependencies
This worked, but when I do
import vimeo
I get this error for tusclient, but I can't do a pip install tusclient
Here is the error message Module Not Found Error.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-13-4cf9739b0a3e> in <module>
----> 1 import vimeo
~\Anaconda3\lib\site-packages\vimeo\__init__.py in <module>
6 version = (0, 3, 10)
7
----> 8 from .client import VimeoClient
9 from . import exceptions
~\Anaconda3\lib\site-packages\vimeo\client.py in <module>
9 from .auth.client_credentials import ClientCredentialsMixin
10 from .auth.authorization_code import AuthorizationCodeMixin
---> 11 from .upload import UploadMixin
12 from .exceptions import APIRateLimitExceededFailure
13
~\Anaconda3\lib\site-packages\vimeo\upload.py in <module>
8 import requests.exceptions
9 from . import exceptions
---> 10 from tusclient import client
11
12 try:
ModuleNotFoundError: No module named 'tusclient'
UPDATE 2:
Okay, so I did pip install tuspy.
So now I can do import vimeo without any error.
However, when I do pip install tuspy, I get this error message.
ERROR: pyvimeo 1.0.11 has requirement tuspy==0.2.1, but you'll have tuspy 0.2.4 which is incompatible.
So not sure this is going to actually work.
When I tried pip install tuspy==0.2.1, I get the pycurl error at the top.
Real hassle.
In your jupyter notebook
type !pip3 install PyVimeo --user

cloudant module will not install with pip

trying to install the cloudant module on a raspberry pi ver 1 rev b using the instructions from IBM's web page.
first: git clone https://github.com/IBM-Cloud/get-started-python
then: cd get-started-python
finally: pip install -r requirements.txt
I want to use the cloudant module with python 2.7 I've read about the environment variable possibly being an issue, but honestly i'm lost. I've read many posts about problems installing, but so far nothing works...
I get the following error message:
pi#rpi-2:~/hms/get-started-python $ pip install -r requirements.txt
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: Flask>=1.0.0 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 1)) (1.0.2)
Collecting cloudant==2.13.0
Using cached cloudant-2.13.0.tar.gz (60 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d8SSO0/cloudant/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d8SSO0/cloudant/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-7Btkkf
cwd: /tmp/pip-install-d8SSO0/cloudant/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-d8SSO0/cloudant/setup.py", line 33, in <module>
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
UPDATE:
so this is my code:
from cloudant.client import cloudant
running my code using python3 code.py I get the error message"
Traceback (most recent call last):
File "code.py", line 1, in <module>
from cloudant.client import cloudant
ModuleNotFoundError: No module named 'cloudant'
While I don't fully understand why changing my import statement to from cloudant import Cloundant fixes the issue...
Parameter encoding was added to open() in Python 3.0. This code in setup.py is Python3-only despite the packages declares compatibility with Python2. Please note they provide wheels only for Python3.
Either using encoding is a bug or declaring compatibility with Python2 is a bug. Which one is for the authors to decide. Report the problem and let's them to resolve.
Or try Python3.

Wrong pip3 python location

I'm in Ubuntu / Linux
I try to install python3.8.2 with the latest version.
before i install i had Version 3.5.2, and that works very well.
but now pip and pip3 is the same linked location:
pip -V
pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
pip3 -V
pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
the problem is why i can't install any packages with the new version error message says:
**
sudo pip3 install nltk
**
WARNING: The directory '/home/fredy/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting nltk
Downloading nltk-3.4.5.zip (1.5 MB)
|████████████████████████████████| 1.5 MB 2.3 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d0mx8gb1/nltk/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d0mx8gb1/nltk/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-d0mx8gb1/nltk/pip-egg-info
cwd: /tmp/pip-install-d0mx8gb1/nltk/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/fredy/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 19, in <module>
from setuptools.dist import Distribution
File "/home/fredy/.local/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/home/fredy/.local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
(pip list)
Package Version
---------- -------
pip 20.0.2
setuptools 46.1.1
(pip3 list)
Package Version
---------- -------
pip 20.0.2
setuptools 46.1.1
step1:
how can i come back to python3 with pip3. ?
step2:
how can i fix the error so i can work with 3.8.2 ?
What will you do ? :)
Thanks for your time !

Categories

Resources