How to properly install virtualenvwrapper to my Mac? - python

I'm trying to follow the Mozilla Django guide:
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/development_environment
Following the steps in the guide, I've successfully installed Python3.7.3 and pip3. When I enter python3 -V and pip3 list I get the expected responses.
Step 1
The next step is to install virtualenvwrapper. I did this with the recommended command:
sudo pip3 install virtualenvwrapper
However when I hit enter I got the following warnings:
The directory '/Users/myusername/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/myusername/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting virtualenvwrapper
Downloading https://files.pythonhosted.org/packages/c1/6b/2f05d73b2d2f2410b48b90d3783a0034c26afa534a4a95ad5f1178d61191/virtualenvwrapper-4.8.4.tar.gz (334kB)
100% |████████████████████████████████| 337kB 9.9MB/s
Collecting virtualenv (from virtualenvwrapper)
Downloading https://files.pythonhosted.org/packages/ca/ee/8375c01412abe6ff462ec80970e6bb1c4308724d4366d7519627c98691ab/virtualenv-16.6.0-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 14.1MB/s
Collecting virtualenv-clone (from virtualenvwrapper)
Downloading https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Collecting stevedore (from virtualenvwrapper)
Downloading https://files.pythonhosted.org/packages/c6/dc/6ee92bccfe3c0448786b30b693e6060d62ec8c4a3ec9a287bac1c1a8d8c9/stevedore-1.30.1-py2.py3-none-any.whl (42kB)
100% |████████████████████████████████| 51kB 28.3MB/s
Collecting pbr!=2.1.0,>=2.0.0 (from stevedore->virtualenvwrapper)
Downloading https://files.pythonhosted.org/packages/e0/27/a913b227c9053472ea7dda33e409a1e748e50cdd208a955f3d6a20e9a875/pbr-5.3.0-py2.py3-none-any.whl (108kB)
100% |████████████████████████████████| 112kB 27.2MB/s
Collecting six>=1.10.0 (from stevedore->virtualenvwrapper)
Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: virtualenv, virtualenv-clone, pbr, six, stevedore, virtualenvwrapper
Running setup.py install for virtualenvwrapper ... done
Successfully installed pbr-5.3.0 six-1.12.0 stevedore-1.30.1 virtualenv-16.6.0 virtualenv-clone-0.5.3 virtualenvwrapper-4.8.4
Step 2
The next step is to edit the file virtualenvwrapper.sh. I can find this in the directory Macintosh HD/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh.
However, when I try to edit the file virtualenvwrapper.sh I get a warning from Xcode saying virtualenvwrapper.sh is currently locked because you are not the owner of the file and do not have write permission.
Solutions
Doing some googling it seems I've got two options:
Install using the sudo -H command and use -H forever more. If so, do I need to uninstall my first installation of virtualenvwrapper + python3 + pip3?
Somehow change the permissions on my machine so I can edit these files. I am the only user of this Mac, so it wouldn't be an issue.
What is the recommended solution?
Thanks in advance for your help.

Related

Trouble installing pyautogui on windows 10

I'm having trouble installing pyautogui, it gives me the following error. By the way, I'm new to python so if I'm not understanding something please explain it to me.
Thanks in advance!
pip install pyautogui
Collecting pyautogui
Using cached https://files.pythonhosted.org/packages/f0/76/7a0ec1013bc3559b7438f6773cba05ffaec600b8989be2d621a144e39b50/PyAutoGUI-0.9.53.tar.gz
Collecting pymsgbox (from pyautogui)
Collecting PyTweening>=1.0.1 (from pyautogui)
Using cached https://files.pythonhosted.org/packages/e9/4f/acb6a2d95260a4377885e40c167fd5df587630696a6a7934675f86aebb06/pytweening-1.0.4.tar.gz
Collecting pyscreeze>=0.1.21 (from pyautogui)
Collecting pygetwindow>=0.0.5 (from pyautogui)
Using cached https://files.pythonhosted.org/packages/e1/70/c7a4f46dbf06048c6d57d9489b8e0f9c4c3d36b7479f03c5ca97eaa2541d/PyGetWindow-0.0.9.tar.gz
Collecting mouseinfo (from pyautogui)
Using cached https://files.pythonhosted.org/packages/28/fa/b2ba8229b9381e8f6381c1dcae6f4159a7f72349e414ed19cfbbd1817173/MouseInfo-0.1.3.tar.gz
Collecting Pillow>=6.2.1; python_version == "3.8" (from pyscreeze>=0.1.21->pyautogui)
Using cached https://files.pythonhosted.org/packages/8f/59/97618ad67fc0639ed588c60cfe9d91417f7bae8c87bbe7c7784b0ffdb9f1/Pillow-9.2.0-cp38-cp38-win_amd64.whl
Collecting pyrect (from pygetwindow>=0.0.5->pyautogui)
Using cached https://files.pythonhosted.org/packages/cb/04/2ba023d5f771b645f7be0c281cdacdcd939fe13d1deb331fc5ed1a6b3a98/PyRect-0.2.0.tar.gz
Collecting pyperclip (from mouseinfo->pyautogui)
Using cached https://files.pythonhosted.org/packages/a7/2c/4c64579f847bd5d539803c8b909e54ba087a79d01bb3aba433a95879a6c5/pyperclip-1.8.2.tar.gz
Installing collected packages: pymsgbox, PyTweening, Pillow, pyscreeze, pyrect, pygetwindow, pyperclip, mouseinfo, pyautogui
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\program files\python38\Lib\site-packages\pymsgbox'
Consider using the --user option or check the permissions.
WARNING: You are using pip version 19.2.3, however version 22.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
The error actually gives you your answer by their recommendation to use the --user option. I run into this as well, if you want to install something without admin privileges. Just add the --user flag to the end of your pip command. This will limit the installation to the current user and not require administrator privileges.
Try this:
pip install pyautogui --user
The second error also gives you the answer of what to do.
pip install --upgrade pip
or, if needed...
pip install --upgrade pip --user

pipenv install django==2.1 not working on google collab

I have already installed pipenv using,
pip install pipenv on the directory which was installed successfully. But
pipenv install Django==2.1 does not seem to work. In fact, no command is getting executed using pipenv.
pip install pipenv
Collecting pipenv
Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB)
100% |████████████████████████████████| 5.2MB 5.5MB/s
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/lib/python3.6/dist-packages (from pipenv) (40.9.0)
Collecting virtualenv-clone>=0.2.5 (from pipenv)
Downloading https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Requirement already satisfied: certifi in /usr/local/lib/python3.6/dist-packages (from pipenv) (2019.3.9)
Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python3.6/dist-packages (from pipenv) (19.0.3)
Collecting virtualenv (from pipenv)
Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 17.1MB/s
Installing collected packages: virtualenv-clone, virtualenv, pipenv
Successfully installed pipenv-2018.11.26 virtualenv-16.4.3 virtualenv-clone-0.5.3
pipenv install Django==2.1
File "", line 1
pipenv install Django==2.1
^
SyntaxError: invalid syntax
*
Anything on Google Colab suggestions would be very helpful!
*
pip is a shell command. I assume Google Colab has made pip available as a special command(*) (without the % syntax), but that doesn't mean any other shell command works as such. That is why you get a SyntaxError: it is not recognised as normal Python syntax.
You can work around it by using !pipenv install 'Django==2.1' (the single quotes may not be necessary, but the exclamation work is).
I doubt, however, that you really need a virtual environment in the first place. This is not on your regular machine, where you may want to keep dependencies apart. Instead, just start a new notebook for a new project, and install Django as normal: pip install Django. I wouldn't bother with pipenv and virtual environments inside notebooks. There doesn't seem to be any use for it.
(*) Try, for example, pip?, and note the help lists its usage with the %pip syntax. I assume that, if it's not ambiguous, Colab will use %pip when called as pip. The same works for, for example, ls instead of %ls.

pipenv install packages for python is not working

I am new to Python and therefore I am struggling to resolve the following problem. I installed pip and I made a user installation of pipenv and then on my project folder I run the command:
pipenv install requests
which gives me an error saying that the pipenv command either wrong or cannot be found.
I added following path on my system environment variables the :
C:\Users\andri\AppData\Roaming\Python\Python37\Scripts
but still it does not work. Does anyone have an idea as to what I should do next in order to fix this? Thanks in advance
UPDATE:
My operating system is Windows.
Here is how I installed pip through cmd
C:\Users\andri>python -m pip install -U pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.5MB/s
Installing collected packages: pip
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Successfully uninstalled pip-18.1
Successfully installed pip-19.0.3
C:\Users\andri>pipenv install requests
Der Befehl "pipenv" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
C:\Users\andri>pip --version
pip 19.0.3 from c:\users\andri\appdata\local\programs\python\python37-32\lib\site-packages\pip (python 3.7)
C:\Users\andri>pip install --user pipenv
Collecting pipenv
Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB)
100% |████████████████████████████████| 5.2MB 2.2MB/s
Requirement already satisfied: setuptools>=36.2.1 in c:\users\andri\appdata\local\programs\python\python37-32\lib\site-packages (from pipenv) (40.6.2)
Collecting virtualenv-clone>=0.2.5 (from pipenv)
Downloading https://files.pythonhosted.org/packages/e3/d9/d9c56deb483c4d3289a00b12046e41428be64e8236fa210111a1f57cc42d/virtualenv_clone-0.5.1-py2.py3-none-any.whl
Collecting virtualenv (from pipenv)
Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 4.7MB/s
Requirement already satisfied: pip>=9.0.1 in c:\users\andri\appdata\local\programs\python\python37-32\lib\site-packages (from pipenv) (19.0.3)
Collecting certifi (from pipenv)
Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
100% |████████████████████████████████| 163kB 837kB/s
Installing collected packages: virtualenv-clone, virtualenv, certifi, pipenv
The script virtualenv-clone.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\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.
The script virtualenv.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\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.
The scripts pipenv-resolver.exe and pipenv.exe are installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\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 certifi-2019.3.9 pipenv-2018.11.26 virtualenv-16.4.3 virtualenv-clone-0.5.1
pip is actually helpfully warning you about this situation right there...
The script virtualenv-clone.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH...
The script virtualenv.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH...
The scripts pipenv-resolver.exe and pipenv.exe are installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH...
You will need to add that directory
C:\Users\andri\AppData\Roaming\Python\Python37\Scripts
to your PATH environment variable; there are many ways to do it, see e.g. Adding directory to PATH Environment Variable in Windows
Another option is to just always use
C:\...> C:\Users\andri\AppData\Roaming\Python\Python37\Scripts\pipenv install
but I think that might get a little stale quickly.
The script virtualenv.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH
There is your answer. The Scripts directory with utility scripts for packages installed per-user is not on PATH, so your command shell won't find them unless you add it.
If you have just added it to PATH via the Control Panel, see windows - Why are changes to my PATH not being recognised? - Super User
I also encounter this same problem, But I quietly not figured out the solution yet. But I realize that It is the problem of the latest version of python. (Python 3.10.5 in my case). Therefore, I downloaded the lower version of python (Python 3.9.9) and it solves the issue.

pip doesn't install anything and tells me to upgrade pip

So whenever I try to install anything pip throws this error:
DEVICE_NAME:~ MY_NAME$ sudo pip install pyautogui
Password:
The directory '/Users/daankoning/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/daankoning/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyautogui
Downloading https://files.pythonhosted.org/packages/2e/83/89b5adbc37d1bbf7b486a2c1c00e8037e6f801e8c053c4897bb82d9510c6/PyAutoGUI-0.9.36.tar.gz (46kB)
100% |████████████████████████████████| 51kB 1.3MB/s
Collecting pymsgbox (from pyautogui)
Downloading https://files.pythonhosted.org/packages/b6/65/86379ede1db26c40e7972d7a41c69cdf12cc6a0f143749aabf67ab8a41a1/PyMsgBox-1.0.6.zip
Collecting PyTweening>=1.0.1 (from pyautogui)
Downloading https://files.pythonhosted.org/packages/b9/f8/c32a58d6e4dff8aa5c27e907194d69f3b57e525c2e4af96f39c6e9c854d2/PyTweening-1.0.3.zip
Collecting Pillow (from pyautogui)
Downloading https://files.pythonhosted.org/packages/df/aa/a25f211a4686f363d8ca5a1752c43a8f42459e70af13e20713d3e636f0af/Pillow-5.1.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.6MB)
100% |████████████████████████████████| 3.6MB 3.5MB/s
Collecting pyscreeze (from pyautogui)
Downloading https://files.pythonhosted.org/packages/9e/ec/e625b7c4f496977eafc441cd1f71becc8436a4ff0714263b885d269d866a/PyScreeze-0.1.14.tar.gz
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
matplotlib 1.3.1 has requirement numpy>=1.5, but you'll have numpy 1.8.0rc1 which is incompatible.
Installing collected packages: pymsgbox, PyTweening, Pillow, pyscreeze, pyautogui
Running setup.py install for pymsgbox ... done
Running setup.py install for PyTweening ... done
Running setup.py install for pyscreeze ... done
Running setup.py install for pyautogui ... done
Successfully installed Pillow-5.1.0 PyTweening-1.0.3 pyautogui-0.9.36 pymsgbox-1.0.6 pyscreeze-0.1.14
You are using pip version 10.0.0b2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
and when I then type pip install --upgrade pip it throws the same error. I've tried reinstalling pip thrice over already and I'm completely out of ideas as to what I can do.
It also does this when I try to install any other package, not jus pyautogui.
Please note that this is only on my OSX machine whilst on my PC it works perfectly fine.
There is always the option downloading a .whl-file and install it with
pip install /some-dir/some-file.whl
I have the same problems as you have with Py 3.4, so i just use Py 3.5. But I know there is no Version of PyAutoGui for 3.x. You can install this package per wheel, and if it is only this package, this'd be ok... Obviously, it does do Pillow...

How to uninstall a package which can't be found in /usr/local/lib

I was following the Flask tutorial and at some point installed an 'incomplete' version of the flaskr micro-blogging app. I would like to 'overwrite' this installation with one obtained from https://github.com/pallets/flask/tree/master/examples/flaskr.
However, in the directory ~/dev/scratch/flask/examples/flaskr, if I try to run
sudo pip install --editable .
I get the following:
The directory '/home/kurt/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kurt/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Obtaining file:///home/kurt/dev/scratch/flask/examples/flaskr
Requirement already satisfied: flask in /usr/local/lib/python2.7/dist-packages (from flaskr==0.0.0)
Requirement already satisfied: itsdangerous>=0.21 in /usr/local/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: click>=2.0 in /usr/local/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: Werkzeug>=0.7 in /usr/local/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: Jinja2>=2.4 in /usr/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: MarkupSafe in /usr/lib/python2.7/dist-packages (from Jinja2>=2.4->flask->flaskr==0.0.0)
Installing collected packages: flaskr
Found existing installation: flaskr 0.0.0
Can't uninstall 'flaskr'. No files were found to uninstall.
Running setup.py develop for flaskr
Successfully installed flaskr
Apparently, pip found an 'existing installation' which it can't uninstall. I'd like to 'wipe out' this installation; however, if I try search for it using, in the directory /usr/local/lib,
find . -name '*flaskr*'
the only result I get is
./python2.7/dist-packages/flaskr.egg-link
If I rm this file, it seems to 'come back' automatically.
How can I re-install the 'flaskr' app cloned from its Github repository?
I solved the problem by going back to the directory I had installed the 'incomplete' version of flaskr from, and running the command
sudo python setup.py develop --uninstall
which produced the confirmation
running develop
Removing /usr/local/lib/python2.7/dist-packages/flaskr.egg-link (link to .)
Link points to ['/home/kurt/dev/scratch/flask/examples/flaskr', '.']: uninstall aborted
Then, going back to the directory with the 'complete' version (~/dev/scratch/flask/examples/flaskr), I ran sudo pip install --editable . followed by export FLASK_APP=flaskr. Then the command
flask initdb
prints the expected output
Initialized the database.

Categories