There was a need to connect the library, but there is no possibility to put it. On the server I am not root, and when you try to put the library gives a type error lacks the entry rights. For my whole happiness, I need a Requests library, can I somehow connect it without installing?
Answer 1, Authority 100%
To install Piton packages, you can do without root. For example, you can create virtualenv in the directory available for recording or install to the user directory:
$ python3 -m Pip Install --user Requests
If at the moment there is no Internet or other way to get the requests
distribution kit, then you can try to use a copy of Requests
, which is enabled in the PIP
installation, which comes with recent versions of Python:
$ python3 -c "from pip._vendor import requests"
In my case Python 2.7.3, I checked on 3 everything works, but on the second it is not very ..
If you can not up to 2.7.9+ updated, where Pip
comes with Python
, then pip
and virtualenv
can be so available separately in the system (Try PIP
, Virtualenv
directly). If they are not available, then enough Download Virtualenv.py
and run it: Python Virtualenv.py name
. In the activated Virtualenv, you can already Pip Install Requests
Run.
Answer 2, Authority 40%
Of course, use virtualenv is the board number one. But if this reason does not roll this method (some hosting providers, for example, do not give such an opportunity), then you can do as follows:
- Set the Requests library to your home computer (I recommend to do it again into VirtuaEnv virtual environment)
- Find in the folder with packages (should be called `Site-Packages’ – look inside the virtual environment if you used it) The Requests
- Create a folder for packages on the computer on which the script will start (let it be / home / username / python-library). Copy there Requests folder.
- in the script that you will run, register somewhere at the beginning:
Import SYS
sys.path.append (/ home / username / python-library)
Now you can safely run the script – it will search for imported libraries in a given folder.
If this is not a script in a single file, but a package, then do it in the__ Main __ file
Library folder