Post Views: 6,845
Here, I will show you how to fix the error “Defaulting to user installation because normal site-packages is not writeable” while installing a package in Python using pip command.
I faced this issue recently while installing openpyxl with pip command. Then I realized this error had nothing to do with a package.
The reason of Defaulting to user installation because normal site-packages is not writeable error
If you are facing this issue that means that the Python version you are using to install the package is invalid for that package.
So make sure the pip and python versions are valid and good to go.
I was using multiple versions of Python at the same time on my machine and that was the issue.
(Nowadays Python is pre-installed with the OS and besides that, we generally install a newer version of Python as well. This is a major reason we are getting this error)
How to fix it
Well, there are multiple ways to fix this and depending upon your current version of pip and python, one of my given methods will fix this error.
If your current Python version is Python3 then run the following command:
python3 -m pip install [pacakge that you are going to install]
For example, if you are going to install opencv and then basic command is pip install opencv-python
But you should run the following command instead of that
python3 -m pip install opencv-python
It should fix your issue.
If you are using python version 2 then do the following:
python -m pip install opencv-python
To install numpy just use:
python3 -m pip install numpy
or
python -m pip install numpy
depending upon the Python version that you are using currently.
What to do if it does not work either
Just specify the exact Python version like this:
python3.7 -m pip install numpy
(If your Python version is 3.7 or change it accordingly)
Having multiple users may also cause permission issues
You can also try these:
pip install numpy --user python -m pip install numpy --user python3 -m pip install numpy --user
or
python3.7 -m pip install numpy --user
If you are using Linux then I will recommend using sudo
before your command.
If you are using Windows then try to run the CMD as administrator.
Just right-click on your CMD and click run as administrator.
The last and most complicated (As well as best) method is creating a virtual env.
You can check this: Create virtual environment using venv
Description
These two errors are always prompted
001:
WARNING: The script f2py.exe is installed in ‘C:\Users\wucha\AppData\Roaming\Python\Python310\Scripts’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use —no-warn-script-location.
002:
Defaulting to user installation because normal site-packages is not writeable
Expected behavior
No response
pip version
21.3.1
Python version
3.10.2
OS
WIN 10
How to Reproduce
pip install numpy or other
I don’t know why this error occurs, but there is no good solution online
Output
001: WARNING: The script f2py.exe is installed in 'C:\Users\wucha\AppData\Roaming\Python\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. 002: Defaulting to user installation because normal site-packages is not writeable 003: C:\Users\wucha>pip install numpy Defaulting to user installation because normal site-packages is not writeable Collecting numpy Using cached numpy-1.22.1-cp310-cp310-win_amd64.whl (14.7 MB) Installing collected packages: numpy WARNING: The script f2py.exe is installed in 'C:\Users\wucha\AppData\Roaming\Python\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed numpy-1.22.1
Code of Conduct
- I agree to follow the PSF Code of Conduct.
In Python, the error message “Defaulting to user installation because normal site-packages is not writeable” usually appears when we try to install packages without having the necessary permissions to write to the system-wide site-packages directory.
Occurrence
This commonly occurs in virtual environments or when we lack administrative access.
Error-resolving approaches
To resolve this error, we can use the following approaches:
-
Using a virtual environment
First, create a virtual environment using tools like venv
or virtualenv
, using this command in the terminal:
-
Python
Когда создаю venv, и когда пытаюсь установить туда что-нибудь через pip, выходит ошибка:
Defaulting to user installation because normal site-packages is not writeable
Устанавливается не в site-packages в venv как это положено, а в путь с моим пользователем в папку AppData\roaming\Python\python38
-
Вопрос задан
-
5721 просмотр
11
комментариев
Подписаться
1
Простой
11
комментариев
-
Версия питона? Версия pip’а?
-
-
Илхомжон Матазимов,
1) А в цифрах?
2) Как создавали virtual environment?
3) Вывод pip list (без venv, из активированного окружения)
4) pip list —outdated (без venv, из активированного окружения
5) requirements.txt
6) С правами на каталог/файлы все в порядке? На самом деле, это первый вопрос.
7) еще можно добавить опции —verbose и —log при запуске pip в активированном окружении.
-
-
Илхомжон Матазимов,
1) Однако, последний питон 3.8.4, но это мелочь.
2) Какая версия PyCharm? Я спрашиваю, потому-что последние версии PyCharm запрашивают адинистративные права для апдейта пакетов в директории Питона. Ну и я сам на нечто подобное недавно нарвался при обновлении Pycharm. Снес вместе с настройками, переставил и восстановил настройки синхронизацией из Jetbraon’овского облака. См. https://youtrack.jetbrains.com/issue/PY-41665 В общем, попробуйте повторить генерацию виртуального окружения, его активацию и запуск pip из командной строки. Мухи отдельно, котлеты отдельно.
6) Ну, если c командной строкой возникнет такая же проблема, то на права доступа таки придется посмотрерть. -
Andy_U, Такая же история. А как проверить права?
-
Andy_U, Дело в том, что не только именно в каком-то каталоге выходит эта ошибка, а вообще в корне. Даже без виртуального окружения
-
Илхомжон Матазимов, Без виртуального окружения — это нормально. Program Files доступны на запись только для администратора (или с elevated правами), т.е. когда вы cmd от админа запускаете.
А сами вы можете каталоги/файлы создавать, редактировать, удалять? А что у вас за антивирус стоит? Может, он запись pip’у блокирует (в песочнице его запускает)?
-
Andy_U, папки создавать/удалять/перетаскивать могу. Антивирус Windows Defender
-
Илхомжон Матазимов, Ну, пожалуй, я сдаюсь. Без физического доступа к компьютеру дальше только если сначала снести питон вместе с директорией из Program Files и потом переустановить с python.org, а если не поможет, операционную систему. Или ищите специалиста, какого-нибудь сисадмина, чтобы он физически посмотрел на ваш компьютер. а так получается удаление гланд по телефону
Python is a scripting language, and there are times when you have to create a Python package and distribute it manually. The problem is that you have to do a lot of extra work to make sure that you can install the Python package. The following blog post will help users solve “Defaulting to user installation when regular site-packages is not writeable” in Python.
Defaulting to user installation when regular site-packages is not writeable
Have you ever attempted to install a package and received the following error:
Defaulting to user installation because normal site-packages is not writeable
The method to fix the “Defaulting to user installation because normal site-packages is not writeable” problem is uninstalling and then reinstalling Python. After that, everything looks to be in working condition. We’re not sure why, but the message “Defaulting to user installation because normal site-packages is not writeable” doesn’t appear anymore.
Approach 1: Reinstall Python
After uninstalling and reinstalling Python, It’s all OK. It seems logical that it wouldn’t print out the message “Defaulting to user installation because normal site-packages is not writeable”.
Approach 2: Update The Python Download Location
Change the Python download path and run cmd as admin/without admin, or both.
Approach 3: Upgrade To The Latest Python Version
Just make sure your Python version is up-to-date.
Approach 4: When Installing The Package, Utilize The Python Version
When installing the package, you need to use the Python version.
Python 3:
python3 -m pip install [package_name]
Python 3.7:
python3.7 -m pip install [package_name]
Python 2:
python -m pip install [package_name]
Conclusion
We hope you enjoyed our article about fixing the “Defaulting to user installation when regular site-packages are not writeable” issue. We are confident that with this information, you will be able to make the most of your Python development experience by installing packages in a user-specific location rather than system-wide.
If you are still having any problems with your Python packages, please feel free to leave us a comment. Thank you for reading; please make sure to share this helpful article with others!
Related Posts
- Top Ways To Create A User-Friendly Online Property Search For Your Real Estate Clients
If you’re running a real estate business, you’re well aware that pretty much most of the paperwork has become automated and it’s time for you really get an education on what you need to use in terms of technology. This is important to make your online presence and services stand out from the competition. Like […]
- List Education Websites for Students, providing a variety of materials and completely free
Everyone would like to get the highest quality of education in order to fulfill their goals. But the more an institution is of high quality and reputable, the more fees they charge. Students typically leave their education in a state of nil and work blue collar jobs to achieve their primary needs. Additionally, they collect […]
- Simple solution to correct the requests.exceptions.ConnectionError: (‘Connection aborted.’ RemoteDisconnected(‘Remote end closed connection without response’)) issue
Python is a popular programming language that can be used widely in a lot of applications. Python is also a good choice as a programming language depending on user background and perspective. Because it is used widely and popular, if you find any errors when using Python. It is a common problem, you face the […]
- “[Errno 61] Connection refused” is occurring even, the program is connecting with the port well and the socket is running in the interfaces.
If you see the “[Errno 61] Connection refused” issue although you checked the program, port, socket and interfaces. Although your program of Python works well in the server and the client, they are installed at the same device. The local IP from my device is connecting with the clients but this IP is not connected […]
- Description “Return by Reference”.
C++ is considered not only as a language of Object Oriented Programming, but also an intermediate level language. It identifies both high and low level languages. It became easy and widely used in computer programs and that is the reason why we should understand the definition and its function as well. Such as Return by […]