My goal is to install a package to a specific directory on my machine so I can package it up to be used with AWS Lambda.
Here is what I have tried:
pip install snowflake-connector-python -t .
pip install --system --target=C:\Users\path2folder --install-option=--install-scripts=C:\Users\path2folder --upgrade snowflake-connector-python
Both of these options have returned the following error message:
ERROR: Can not combine '--user' and '--target'
In order for the AWS Lambda function to work, I need to have my dependencies installed in a specific directory to create a .zip file for deployment. I have searched through Google and StackOverflow, but have not seen a thread that has answered this issue.
Update: This does not seem to be a problem on Mac. The issue described is on Windows 10.
We encountered the same issue when running pip install --target ./py_pkg -r requirements.txt --upgrade with Microsoft store version of Python 3.9.
Adding --no-user to the end of it seems solves the issue. Maybe you can try that in your command and let us know if this solution works?
pip install --target ./py_pkg -r requirements.txt --upgrade --no-user
We had the same issue just in a Python course: The error comes up if Python is installed as an app from the Microsoft app store. In our case it was resolved after re-installing Python by downloading and using the installation package directly from the Python website.
I got a similar error recently. Adding my solution so that it might help someone facing the error due to the same reason.
I was facing an issue where all my pip installed packages were going to an older python brew installation folder.
As part of debugging, I was trying to install awscli-local package to user site-package using:
pip install --user awscli-local
Then I got:
ERROR: cannot combine --user and --target
In my case, it was due to the changes in pip config I had set some time back for some other reason.
I had set the 'target' config globally - removing which removed this error and my actual issue I was debugging for.
Check the following if solutions given above doesn't resolve your issue:
try the command:
pip config edit --editor <your_text_editor>
For me:
pip config edit --editor sublime
This will open the current config file where you can check if there's any conflicting configuration like the 'target' set in my case.
Adding --no-user at the end does work, and by far the easiest solution.
Related
On Windows, if you try to use pip to upgrade itself, inside a virtualenv, you may get a mysterious "access is denied" error. For instance:
D:\scratch\> C:\Program Files\Python\3.7.4\x64\python.exe -m venv D:\scratch\my-venv
D:\scratch\> D:\scratch\my-venv\Scripts\activate
(my-venv) D:\scratch\> pip install --upgrade pip
Collecting pip
Downloading pip-19.3.1-py2.py3-none-any.whl (1.4MB)
Installing collected packages: pip
Found existing installation: pip 19.0.3
Uninstalling pip-19.0.3:
Could not install packages due to an EnvironmentError:
[WinError 5] Access is denied: 'd:\\scratch\\my-venv\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.
This happens whether or not the command prompt has administrative privileges.
We know we have write access to everything inside d:\scratch\my-venv, because we just created it with the initial python -m venv command. The advice to use the --user option is unhelpful, since we want to upgrade the version of pip inside the virtualenv, which --user will not do.
What could be wrong, and what is the correct way to upgrade pip inside a virtualenv on Windows?
I don't know if this is the only reason this can happen, but notice that the "Access is denied" error points at d:\scratch\my-venv\scripts\pip.exe. pip is trying to replace itself, and Windows doesn't allow you to modify a running EXE file in any way.
A workaround for this specific problem is to use python -m pip install --upgrade pip instead. This way, pip.exe is not running, so Windows will allow it to be replaced. This action doesn't try to overwrite d:\scratch\my-venv\scripts\python.exe, and Windows doesn't care what pip does to all the other files belonging to the pip package.
See https://github.com/pypa/pip/issues/188 and https://github.com/pypa/pip/issues/1299 for further information.
You must have the same version of pip installed in windows as in the virtual env. I think that is the reason for the error Access Denied in Virtual Env.
in promt,
python -m pip install --upgrade pip
located in the Scripts folder of the virtual env, execute the update command upgrade pip in venv
I would have put this in a comment to zwol's answer, but I don't have enough reputation yet.
I just wanted to add to anyone else potentially coming across this from google like I did, that python -m pip install --upgrade pip did fix this issue for me. However if you try pip install --upgrade pip before doing that, something happens in the process before you hit the access denied error that messes up pip. I personally was getting ModuleNotFoundError: No module named 'pip' after trying to upgrade the normal way.
Once I deleted and restarted my virtualenv and had the first command be python -m pip install --upgrade pip It worked just fine.
I hope that helps other newbies out there struggling like me! :)
Same error for me, but in both conditions: my system pip and virtualenv pip. So, when I tried to upgrade my system pip, hopefully it wasn't like totally deleted, I could still use the "pip" command. However I know the upgrade system pip failed. When I tried the command again, it said pip was on the latest version. Maybe this is just a glitch. I believe it is the same for virtual environments(virtualenv, venv). When I upgrade the system pip I get this error:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\heewo\\AppData\\Local\\Temp\\pip-uninstall-8ob_krif\\pip.exe'
Consider using the `--user` option or check the permissions.
I know this is not normal. But still, different than the virtualenv, "pip" is still installed. I believe this is still ignorable as this is just a known issue and most people here know about this topic. For me, python -m pip install --upgrade pip did not work in this state.
I tried this method, and this did work for me.
virtualenv --pip [VERSION]
and replace VERSION with the latest version available on pip. This prints out that what version you are attempting to upgrade to, when you get the error.
And that should do the trick.
I am trying to get the requirements for my code into a local package following this guide:
https://docs.aws.amazon.com/lambda/latest/dg/python-package.html
In step one when I try to run a similar command pip install --target ./package -r requirements.txt it fails with the following error "ERROR: Can not combine '--user' and '--target'". I have no idea why it is complaining.
I am using PyCharm, with a conda environment, and I am running the commands in the PyCharm Terminal.
I found this question/answer: PIP Install: Cannot combine --user and --target
but I am not using the Microsoft store version of python. My PyCharm project is configured to use the Anaconda python interpreter.
Update: I was able to get the command to succeed by installing pip inside of the conda environment I am using but I am still not sure why it was an issue before. If anyone has any details it would be appreciated.
Let me know what details are needed, thanks.
If you are trying to install them all in the same directory try:
pip install -r requirements.txt -t ./package
I am trying to install web3.py through the command pip install web3 however I cannot succeed without getting an error.
I have tried the advice on this website however that did not work, below is the error that I receive:
Error
Full Console Log
As advised here in a related stackoverflow thread, grab various wheel files that are required from here.
In this case it seems you are failing at cytoolz so you can manually install the whl files.
Let's say you are running a 64 bit environment, you can download cytoolz‑0.10.1‑cp38‑cp38‑win_amd64.whl file and run pip install cytoolz‑0.10.1‑cp38‑cp38‑win_amd64.whl in the same directory as your whl file
Since this is probably windows platform you are using, you need to install Microsoft C++ build tools and then also add them to your path, if it still doesn't work I suggest switching to Linux or using WSL
You may need to install those packages
sudo apt install python3-dev
sudo apt-get install libevent-dev
sudo apt update
Related answers
I always install packages with the command "python -m pip install " in cmd. Today I got the notification that I am using pip and pip 20.1.1 can be installed by typing "python -m pip install --upgrade pip". I did that and now pip fails to install or uninstall programmes. This is the error message I get when trying to install a new package.
ImportError: cannot import name 'webencodings' from 'pip._vendor' (C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_vendor\__init__.py)
I am a complete beginner and don't want to mess to much with the pip directory, is there an easy solution for my problem?
It looks like this has been happening with pip 20+ when your "system" pip install gets incorrectly upgraded -- it's honestly pretty messed up that the default upgrade command that pip itself tells you to use does this "wrong" upgrade.
See this issue for a detailed discussion, a bunch of related issues, and some workarounds. This more recent report has a bunch of people reporting the same for pip20.
Potentially the easiest solution is to uninstall it:
python -m pip uninstall pip
Which should bring you back to the "system" pip installation. And then just ignore the warning, or only work inside virtualenvs, where you shuold be able to safely use updated pip.
Another possible workaround is to install an older version manually using the get-pip script:
python get-pip.py pip==19.3.1
Note: If anyone has better advice please feel free to comment / correct me.
I'm relatively new to Python, extremely new to Django and Heroku, and also rather new to working in the terminal.
I'm attempting to follow the instructions on setting up a Django Heroku project found here. I'm getting stuck at the following command:
pip install django-toolbelt
I keep getting the following error:
Error: pg_config executable not found.
I don't know if any of this is even remotely related to the problem, but these are the things I've tried so far:
Tried reinstalling the django-toolbelt (just running the command again)
Tried switching from Postgres.app to the full Mac OSX install
No luck. What am I missing?
EDIT: Per Midimo's suggestion, I tried installing python-dev. This is what happened:
(venv)Macbook:[SITE] [USER]$ pip install python-dev
Downloading/unpacking python-dev
Could not find any downloads that satisfy the requirement python-dev
Cleaning up...
No distributions at all found for python-dev
Storing complete log in /Users/[USER]/.pip/pip.log
EDIT 2: And this is what happened when I tried to install libpq-dev...
(venv)Macbook:[SITE] [USER]$ pip install libpq-dev
Downloading/unpacking libpq-dev
Could not find any downloads that satisfy the requirement libpq-dev
Cleaning up...
No distributions at all found for libpq-dev
Storing complete log in /Users/[USER]/.pip/pip.log
do you have python-dev installed?
If you did, try installing libpq-dev
Before installing django-toolbelt you have to install those following dependencies:
$ sudo apt-get install python-dev python-psycopg2 libpq-dev
And then in the virtualenv:
(myven)trinh#trinh-pc:/path/to/django/project$ pip install django-toolbelt
Source :
I had same problem: one of the messages was couldn't run pg_config. Despite fact I had pg_config on my PATH and had restarted terminal to be sure.
My solution was to just run pg_config right before pip install django-toolbelt.
install than ran without any errors.
Just in case this will help anyone.
I'm working through this on Windows and was having this problem while trying to install django-toolbelt via pip in a virtualenv.
I had to add the entire directory to my PATH and make sure that Program Files was in quotes --
PATH=$PATH:/c/"program files"/postgresql/9.4/bin/
I was trying to get this work for hours so hopefully this helps someone else!
You need Postgres on you Mac because the django-toolbelt will try to install psycopg2 that won't find the path for the database and will raise the error.
The easiest solution is to install the Postgres.app and then add to the .profile file located on your home folder the following and restart or just run the command manually in the terminal:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
Now you are ready to install the toolbelt