Skipping pyspark pip package when I want to insatlll other packages - python-3.x

I am trying to install apcjckage named elephas by using its wheel file on windows, however. it has some requirments for pyspark and kers, I cant install pyspark on my anaconda due to firewall isssues on my PC. I have juts unzip pyspark and I am using it but , I want to know if there is anyway to skip the pyspark when installing elephas.
(base) C:\Users\Public>python -m pip install elephas-0.4.2-py3-none-any.whl
Processing c:\users\public\elephas-0.4.2-py3-none-any.whl
Requirement already satisfied: hyperas in c:\users\kmob\appdata\local\continuum\anaconda3\lib\site-packages (from elephas==0.4.2) (0.4.1)
Requirement already satisfied: keras in c:\users\kmob\appdata\local\continuum\anaconda3\lib\site-packages\keras-2.2.4-py3.7.egg (from elephas==0.4.2) (2.2.4)
Requirement already satisfied: flask in c:\users\kmob\appdata\local\continuum\anaconda3\lib\site-packages (from elephas==0.4.2) (1.1.1)
Requirement already satisfied: cython in c:\users\kmob\appdata\local\continuum\anaconda3\lib\site-packages (from elephas==0.4.2) (0.29.12)
Requirement already satisfied: tensorflow in c:\users\kmob\appdata\local\continuum\anaconda3\lib\site-packages (from elephas==0.4.2) (1.14.0)
Collecting pyspark (from elephas==0.4.2)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000000044F8358>, 'Connection to pypi.org timed out. (con
nect timeout=15)')': /simple/pyspark/
it cant download pyspark from the source since I have firewall, I have pyspark unzipped on my local machine and I can run it, is there anyway to skip the above pyspark installation check?

Related

pip3 install reads from setup.cfg

I am on Ubuntu 21.10 and created a small python package which also consists of a setup.py and setup.cfg file. In my setup.cfg there are these lines:
[install]
install_scripts = /etc/icinga2/scripts
Now when I am in that directory and try to install virtualenv or any other package I get this:
nicolas#tp-t14:~/git/test$ pip3 install virtualenv
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Defaulting to user installation because normal site-packages is not writeable
Collecting virtualenv
Using cached virtualenv-20.14.1-py2.py3-none-any.whl (8.8 MB)
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv) (1.16.0)
Requirement already satisfied: filelock<4,>=3.2 in /home/nicolas/.local/lib/python3.9/site-packages (from virtualenv) (3.7.0)
Requirement already satisfied: platformdirs<3,>=2 in /usr/local/lib/python3.9/dist-packages (from virtualenv) (2.5.1)
Requirement already satisfied: distlib<1,>=0.3.1 in /home/nicolas/.local/lib/python3.9/site-packages (from virtualenv) (0.3.4)
Installing collected packages: virtualenv
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
ERROR: Could not install packages due to an OSError: [Errno 13] Keine Berechtigung: '/etc/icinga2'
Check the permissions.
Why does pip3 reads from setup.cfg when I only want to install a package. It also happens with other packages I want to install. If I remove these lines from the setup.cfg file the installation works flawlessly and looks like this:
nicolas#tp-t14:~/git/test$ pip3 install virtualenv
Defaulting to user installation because normal site-packages is not writeable
Collecting virtualenv
Using cached virtualenv-20.14.1-py2.py3-none-any.whl (8.8 MB)
Requirement already satisfied: platformdirs<3,>=2 in /usr/local/lib/python3.9/dist-packages (from virtualenv) (2.5.1)
Requirement already satisfied: filelock<4,>=3.2 in /home/nicolas/.local/lib/python3.9/site-packages (from virtualenv) (3.7.0)
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv) (1.16.0)
Requirement already satisfied: distlib<1,>=0.3.1 in /home/nicolas/.local/lib/python3.9/site-packages (from virtualenv) (0.3.4)
Installing collected packages: virtualenv
Successfully installed virtualenv-20.14.1
There are even no DEPRECATION warnings anymore.
I only want to understand the background of that because I now struggled quite a lot of time with my deployment scripts here because of that.

pip in a (mini)conda environment installs packages in the global site-packages directory

As the answer to this question indicates, pip in a conda-env should install a package in the site-packages directory of env's python. In my case, however, pip (launched within the env) is trying to install in the global python site-packages.
Additionally, the installation in the site-packages of my global python is not so very clean either: newly installed packages fall under /Users/massimopinto/Library/Python/3.9/site-packages/Users/massimopinto/Library/Python/3.9/site-packages , that is the directory is nested within itself, so I need to manually move the new package to make it usable.
Would a re-configuration of pip work? Any advice would be much appreciated.
pip in use (21.2.4):
(spekpy) massimopinto#MacBook-Air-2 spekpy_release % which pip
/Users/massimopinto/opt/miniconda3/envs/spekpy/bin/pip
(env's) pip configuration:
(spekpy) massimopinto#MacBook-Air-2 spekpy_release % pip config list
freeze.timeout='10'
global.editor='vim'
global.timeout='60'
home's pip configuration:
(spekpy) massimopinto#MacBook-Air-2 spekpy_release % cat ~/.pip/pip.conf
[global]
timeout = 60
[freeze]
timeout = 10
running on a MacOS Monterey 12.0.1, conda 4.10.3, Python 3.9.7.
Edited
As at a suggestion by #flyingteller, the output of
/Users/massimopinto/opt/miniconda3/envs/spekpy/bin/python -m pip install . >> spekpy-install.log
is
Processing /Users/massimopinto/Progetti Git/spekpy_release
Requirement already satisfied: scipy in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from spekpy==2.0.6) (1.7.1)
Requirement already satisfied: matplotlib in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from spekpy==2.0.6) (3.4.3)
Requirement already satisfied: pyparsing>=2.2.1 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (3.0.4)
Requirement already satisfied: numpy>=1.16 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (1.21.2)
Requirement already satisfied: kiwisolver>=1.0.1 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (1.3.1)
Requirement already satisfied: python-dateutil>=2.7 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (2.8.2)
Requirement already satisfied: cycler>=0.10 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (0.11.0)
Requirement already satisfied: pillow>=6.2.0 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (8.4.0)
Requirement already satisfied: six>=1.5 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib->spekpy==2.0.6) (1.16.0)
Building wheels for collected packages: spekpy
Building wheel for spekpy (setup.py): started
Building wheel for spekpy (setup.py): finished with status 'done'
Created wheel for spekpy: filename=spekpy-2.0.6-py3-none-any.whl size=66391250 sha256=86962e10ec6182d7f0522dcf0d3e1d264b9d16d3659d5d5af038631d99bd8039
Stored in directory: /private/var/folders/qs/hcv45zhn46q0p6xwndbc51fw0000gn/T/pip-ephem-wheel-cache-etx845ts/wheels/c3/93/d0/2db997ad51d9b10f0b0acac3a1f27240cca3d41a8cac3265ab
Successfully built spekpy
Installing collected packages: spekpy
Successfully installed spekpy-2.0.6
but the installation is still in
/Users/massimopinto/Library/Python/3.9/site-packages/Users/massimopinto/Library/Python/3.9/site-packages/spekpy

Errors while installing matplotlib using pip install

I updated my Python3 to Python 3.10. It still is showing Python 3.8 as my current version. but that's not the issue. My issue is that when I went to install the matplotlib package using pip install matplotlib, I got some errors. I also tried running pip3 install matplotlib. I got the following errors:
WARNING: Retrying (Retry(total=4, connect=None, read=None,
redirect=None, status=None)) after connection broken by
'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection
object at 0x1057db7c0>: Failed to establish a new connection: [Errno
8] nodename nor servname provided, or not known')':
/simple/matplotlib/
ERROR: Could not find a version that satisfies the requirement
matplotlib (from versions: none) ERROR: No matching distribution found
for matplotlib
The I tried running /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -m pip install --upgrade pip and got the following error:
Defaulting to user installation because normal site-packages is not
writeable.
Requirement already up-to-date: pip in
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages
(20.2.3)
I don't get it. It wanted me to upgrade pip and then says it's already up to date?
I just need the matplotlib module installed for my Python scripts.
If you are trying to install matplotlib in your organisation laptop then your organsiation could be blocking the network to connect and download the package. This is one reason its showing retrying error message. You can try disconnecting vpn if you are connecting with any and retry installing it. This error is due to network issue only.

NOT able to import Folium after showing folium in conda list

I have installed folium using both pip and conda , it got successfully installed infact conda list in particular environment also showing still i can not be able to import the folium.
#Instructions i followed to installed folium are below:-
(ML) C:\Users\24HOURS>pip3 install folium
Requirement already satisfied: folium in c:\users\24hours\miniconda3\envs\ml\lib
\site-packages (0.10.1)
Requirement already satisfied: numpy in c:\users\24hours\miniconda3\envs\ml\lib\
site-packages (from folium) (1.19.2)
Requirement already satisfied: requests in c:\users\24hours\miniconda3\envs\ml\l
ib\site-packages (from folium) (2.25.1)
Requirement already satisfied: branca>=0.3.0 in c:\users\24hours\miniconda3\envs
\ml\lib\site-packages (from folium) (0.4.2)
Requirement already satisfied: jinja2>=2.9 in c:\users\24hours\miniconda3\envs\m
l\lib\site-packages (from folium) (2.11.3)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\24hours\miniconda3\e
nvs\ml\lib\site-packages (from jinja2>=2.9->folium) (1.1.1)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\24hours\miniconda3\
envs\ml\lib\site-packages (from requests->folium) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in c:\users\24hours\miniconda3\envs\
ml\lib\site-packages (from requests->folium) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\24hours\minicon
da3\envs\ml\lib\site-packages (from requests->folium) (1.26.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\24hours\miniconda3
\envs\ml\lib\site-packages (from requests->folium) (2020.12.5)
conda way installation below:-
(ML) C:\Users\24HOURS>conda install -c conda-forge folium
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.9.2
latest version: 4.10.0
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: C:\Users\24HOURS\miniconda3\envs\ML
added / updated specs:
- folium
The following packages will be UPDATED:
ca-certificates conda-forge/label/cf202003::ca-certif~ --> conda-forge::ca-
certificates-2020.12.5-h5b45459_0
folium conda-forge/label/cf202003::folium-0.~ --> conda-forge::fol
ium-0.12.0-pyhd8ed1ab_1
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(ML) C:\Users\24HOURS>
Still I am getting import Error for folium
In jupyter notebook
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-173c1173bf1c> in <module>
----> 1 import folium
ModuleNotFoundError: No module named 'folium'

WARNING: ansible 2.10.3 does not provide the extra 'azure'

I'm trying to install Ansible for Azure development on WSL2 (Ubuntu 20.04) but see the following output when trying to install:
> pip3 install 'ansible[azure]'
Looking in indexes
Processing /home/ross/.cache/pip/wheels/73/11/5d/0fd1ddb1a82c6afefa3f475b62f3f35c9224aef05a37d330ed/ansible-2.10.3-py3-none-any.whl
WARNING: ansible 2.10.3 does not provide the extra 'azure'
Requirement already satisfied: ansible-base<2.11,>=2.10.3 in /home/ross/.local/lib/python3.8/site-packages (from ansible[azure]) (2.10.3)
Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.3->ansible[azure]) (5.3.1)
Requirement already satisfied: jinja2 in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.3->ansible[azure]) (2.10.1)
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from ansible-base<2.11,>=2.10.3->ansible[azure]) (2.8)
Requirement already satisfied: packaging in /home/ross/.local/lib/python3.8/site-packages (from ansible-base<2.11,>=2.10.3->ansible[azure]) (20.4)
Requirement already satisfied: pyparsing>=2.0.2 in /home/ross/.local/lib/python3.8/site-packages (from packaging->ansible-base<2.11,>=2.10.3->ansible[azure]) (2.4.7)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from packaging->ansible-base<2.11,>=2.10.3->ansible[azure]) (1.14.0)
Installing collected packages: ansible
Successfully installed ansible-2.10.3
As a result, when I try and run a playbook using Azure modules, it fails:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on mypc's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
I am using python3 and pip3.
Is there something else I need to do in order to install Azure modules for Ansible?
Since version 2.10 of ansible, quite a few modules have been moved to external collections and are not part of the core of ansible anymore. You need to install those collections in your local ansible environment if you intend to use them.
Please follow the guide to install azure.azcollection. Very basically:
curl -O https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt
pip install -r requirements-azure.txt
rm requirements-azure.txt
ansible-galaxy collection install azure.azcollection

Resources