I have a python script running in a instance inside a private subnet, that script requires external libraries such as boto3. I can't install them using something like pip3 install boto3 because private instances don't have access to the internet. How can I do this?
If you really want to install everything offline, you can create a list of required packages with pip download install each of them individually with pip install <package_name.whl>:
1.Use venv on internet-connected machine to isolate requirements from your system setup
mkdir ~/package-requirements
python3 -m venv ~/package-requirements
source ~/package-requirements/bin/activate
2.Download desired package and all requirements as .whl files:
pip3 download pandas
Copy all .whl files from your work directory to target machine and install each of them individually:
pip3 install numpy-1.21.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
pip3 install pytz-2021.1-py2.py3-none-any.whl
pip3 install six-1.16.0-py2.py3-none-any.whl
pip3 install python_dateutil-2.8.2-py2.py3-none-any.whl
pip3 install pandas-1.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Related
I tried to install PyMuPDF on Python 3.9 when first I installed by pip install PymuPDF and re-checked by pip list like this"
But when I imported PyMuPDF:
ModuleNotFoundError: No module named 'PyMuPDF'
Next, I tried to install PymuPDF from doc, it said I need install MuPDF first, and install with Wheel, I tried both:
pip install C:\Users\Admin\Desktop/PyMuPDF-1.19.6-cp310-cp310-win_amd64.whl and pip install PyMuPDF-1.19.6-cp310-cp310-win_amd64.whl but reviced error:
yMuPDF-1.19.6-cp310-cp310-win_amd64.whl is not a supported wheel on this platform.
What should i do to install PyMuPDF, thank you all.
PyMuPDF is available with a wheel under all Windows versions - you should have no problem at all.
But please follow this procedure:
Make sure your pip is the current one. This ensures that any changes in supported platform tags are known to pip.
Then install PyMuPDF.
So overall
py -3.10 -m pip install -U pip
py -3.10 -m pip install -U pymupdf
This should simply work!
In your script however you must do import fitz - this is the top-level name of the package.
I know that pip list will show the lis of installed packages. But I am wondering is there command in pip which will help you to copy all the installed packages into a text file requirements.txt? Also, is there a way to install all the packages using this requirement.txt and not using pip install command for each and every package.
pip freeze > requirements.txt
to create requirements file. And
pip install -r requirements.txt
to auto install packages
-r flag uses a requirements file to install packages
pip freeze > requirements.txt
to generate a requirements file and
pip install -r requirements.txt
to install packages from this file.
There is a need to install python packages on machine without internet connection
I used pip download to download the packages and their dependencies
I copied all the dependencies to the offline machine
I run pip from the local python packages repository using
pip install *
package with dependencies are trying to access the internet to download their dependencies even that they are locate in the same directory
I would like to avoid the requirement.txt file and would like it to install all the packages from the local directory with their dependencies.
Is there any way to do so?
It's possible to download the wheels directly for each package, and once you have them on the machine you can run pip install name-of-wheel.whl and it will install them without routing to pypi.
You can use on the online machine:
pip download -r requirements.txt
to download package without installing them.
Then, on the offline machine:
pip install --no-index --find-links /path/to/download/dir/ -r requirements.txt
Source: Python Packages Offline Installation
I am not sure what is wrong but I can't seem to get python3 in a virtualenv environment. I tried upgrading my ubuntu and updating all the packages - but no luck:
python3 -m virtualenv ENV
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/ramin/projects/buybulkamerica/ENV/bin/python2
Also creating executable in /home/ramin/projects/buybulkamerica/ENV/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
What can I do to ensure that virtualenv installs python3 instead of python2?
First, uninstall existing virtualenv.
sudo apt-get remove --purge python-virtualenv if you installed it using a package manager.
pip uninstall virtualenv if you have installed it using pip.
pip3 uninstall virtualenv if you have installed it using pip3.
Any one of the above commands will work.
Now install virtualenv again. Since you want python3, you need to run the following command.
pip3 install virtualenv
That should do the trick. Now when you create a new virtualenv, it will use python3.
There may be a better way but I had the same problem and after not finding any solution I tried this and it worked.
After you have installed virtualenv using pip, it doesn't matter if you used pip or pip3 if you give the location of your python3 installation to the virtualenv command, like this.
Create new virtualenv
virtualenv --python=/usr/bin/python3.6 environmentname
Access virtualenv
source /environmentname/bin/activate
If this doesn't work, use complete path from pwd
source /complete/path/to/environmentname/bin/activate
Stop virtualenv
deactivate
I have seen answers here but couldn't find one that solved my issue. I want to install midi, midi_manipulation for python3 on Linux. This is what I have tried uptil now:-
sudo pip3 install python3-midi
sudo pip install midi_manipulation
sudo pip install midi
sudo pip3 install midi
sudo pip install python-midi
I have downloaded other packages using the exact same format and just the different package name but why isn't it working for midi? Any help will be highly appreciated.
Because there is no midi_manipulation at PyPI (do you know where from pip installs packages?) and there is package midi but it doesn't contain any downloadable files. The only way is to download source code from release or install directly from Github:
pip install git+https://github.com/vishnubob/python-midi.git#egg=midi