I got my pip install directory in
/Library/Python/2.7/site-packages
Somehow, after I install the wordbatch library, my pip install path changes to
/usr/local/lib/python2.7/site-packages
Does anyone know how to change the pip install path?
One idea is you can just install it anywere. Then move it to the correct directory. This should fix the problem, if you want it to install there from the start. Then i don't know.
You can see help of pip install in bash like pip install --help.
Current task you need use parameters --target /usr/local/lib/python2.7/site-packages.
Related
I've never done any Python so I'm not familiar with the package versions and dependencies system overall. I'm trying to run this repo https://github.com/Maaxion/homeassistant2influxdb
For this, I want to use Docker. So once I've cloned the repo, I've added this Dockerfile at the root and followed what was explained in the readme to the best I could:
FROM ubuntu:18.04
RUN apt update -y
RUN apt install python3 python3.7-dev python3-venv python3-pip git -y
WORKDIR /home
COPY . .
RUN git clone --depth=1 https://github.com/home-assistant/core.git home-assistant-core
RUN python3 -m venv .venv
RUN . .venv/bin/activate
RUN python3 -m pip install --upgrade --force pip
RUN pip3 install -r home-assistant-core/requirements.txt
RUN pip3 install -r requirements.txt
It goes fine until it tries to install with pip3 with that line: pip3 install -r home-assistant-core/requirements.txt and I get:
Collecting atomicwrites-homeassistant==1.4.1
Downloading atomicwrites_homeassistant-1.4.1-py2.py3-none-any.whl (7.1 kB)
ERROR: Cannot install awesomeversion==22.9.0 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested awesomeversion==22.9.0
The user requested (constraint) awesomeversion==22.9.0
To fix this you could try to:
loosen the range of package versions you've specified
remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
I'm really not sure how to solve this despite taking a look at the link above...
Is it something to do with pip3? Have I missed something in the Dockerfile? How can I solve that issue? I've been looking online but there doesn't seem to be silver bullet answer for this kind of issues.
Could anyone provide some guidance? Thanks!
Try not to specify a direct version, like awesomeversion>=22.4.0 in your requirements.txt file.
What has probably happened is that one of the other requirements is specified as coolRequirement >= somenumber, (or just coolRequirement).
This means that pip is grabbing the latest recommended release for your python version. One of these requirements probably conflicts with something that awesomeversion==22.9.0 requires. One possible solution would be to change awesomeversion==22.9.0 to awesomeversion>=22.9.0, but that may not work if newer versions of awesomeversion break something else.
The real solution would be to figure out what versions of the other requirements worked in the past, and lock those down the same way that awesomeversion is specified.
I have found that I can pip install packages to a certain directory using:
!pip install --target='/content/drive/Mydrive/requirements' <package_name>
In the above case, I can see <package_name> in the folder '/content/drive/Mydrive/requirements'. However, when I install packages from a file, 'requirements.txt', the packages do not go into the target directory, namely:
!pip install --target='/content/drive/Mydrive/requirements' -r requirements.txt
Does not install the packages in 'requirements.txt' into '/content/drive/Mydrive/requirements'.
Can somebody please help? Thanks!
I realized what was needed ... (below)
!pip install -r requirements.txt -t "target_dir"
I think where the "-r" flag is seemed to matter, but then again I had tried that but it didn't work before. However, what I have here does work.
pip3 install "package_name" -t "target_dir"
I think I uninstalled pip by mistake ^^
I ran something like "pip uninstall pip" in CMD and it completely broke, giving fatal errors.
I uninstalled and reinstalled python, added the correct folders back to PATH, but now it's only working via python -m pip XXXX and not by typing pip XXXX...
If I type pip XXX i get an empty row and CMD gives me back the cursor.
How can I recover? I liked pip XXX better and I am sure that the pip folder is in PATH.
It would help greatly to know what version of each you are using and what OS but for a generic answer...
You could try to install it manually:
Vist:
https://pip.pypa.io/en/stable/installing.html
Download:
get-pip.py
python get-pip.py
Make sure your python version matches your pip version. Otherwise you will always have to be specific on your installs. And for sake of simplicity make sure it works fine with just one version of Python installed. Then if that works you can consider having more.
After installing it, if you upgrade your python version make sure you keep it up to date.
I would try something like:
pip install --upgrade --no-deps --force-reinstall
As os version 21.3.1, you can install pip with the one-liner:
python -m ensurepip --upgrade.
See installation of pip doc for details.
I'm on OS X and my Pip installs to
/Library/Python/2.7/site-packages
I would like my pip to install to:
/usr/local/lib/python2.7/site-packages
How could I achieve this? I haven't found a way yet
pip has an option for target directory --target, when installing package use
pip install --target=/usr/local/lib/python2.7/site-packages package_name
to install to your target directory.
if target option not available, check pip version & for possible
upgrade or as mentioned in comments the error may be related to OSX/Homebrew install, check here for details.
We have a python/django based web application, many components of which are installed using pip. So I would like to ask if there is a way to save or download and save the particular python packages that we are having pip install (example: pip install django==1.5.1). We would like to have in the end a collection of the packages in the versions known to be working and with which the app was developed locally. Any and all advice will be appreciated.
If I understood your question right, you can pip freeze > requirements.txt, this command will add all the libraries you have used/"downloaded" for your app in the file requirements.txt(in case it exists the file be overwritten). This command allows you to later do pip install -r requirements.txt. However, be aware that your Django project must be running in a virtual environment, otherwise the install command will attempt to install all the python packages in your development machine.
The freeze command will allow you to have the current version of the app so upon installation will attempt to install that same version. Your requirements file will look something like:
Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
gunicorn==0.14.2
requests==0.11.1
Your packages are installed (if using virtualenv) at: ../<your project>/<your virtual env>/<lib>/<python version>/<site-packages>/
As for downloading you can use pip install --download command as #atupal suggested in his response, however think if this is really needed you can also fork those libraries on github to accomplish the same.
Here is a good source of information on how this works: http://www.pip-installer.org/en/latest/cookbook.html
Maybe what you want is:
Download the packages:
pip install --download /path/to/download/to packagename
OR
pip install --download=/path/to/packages/downloaded -r requirements.txt
install all of those libraries just downloaded:
pip install --no-index --find-links="/path/to/downloaded/dependencies" packagename
OR
pip install --no-index --find-links="/path/to/downloaded/packages" -r requirements.txt
Shamelessly stolen from this question
Create a requirements.txt file.
Put:
django==1.5.1
in the first line.
Then run pip install -r requirements.txt
Then you can complete that file...