pipenv install django==2.1 not working on google collab - python

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.

Related

Error: subprocess-exited-with -error. --python

Error: subprocess-exited-with -error, python setup.py egg_info did not run successfully.
I know that there are some similar questions. But the error still exist after trying those solution. I want to install a model called midi-ddsp and it shows an error.
Requirement already satisfied: music21 in ./Library/Python/3.8/lib/python/site-packages (from midi-ddsp) (7.3.3)
Requirement already satisfied: pandas in ./Library/Python/3.8/lib/python/site-packages (from midi-ddsp) (1.3.3)
Requirement already satisfied: pretty-midi in ./Library/Python/3.8/lib/python/site-packages (from midi-ddsp) (0.2.9)
Requirement already satisfied: mir-eval in ./Library/Python/3.8/lib/python/site-packages (from ddsp==3.2.0->midi-ddsp) (0.7)
Requirement already satisfied: tensorflow-addons in ./Library/Python/3.8/lib/python/site-packages (from ddsp==3.2.0->midi-ddsp) (0.17.1)
Requirement already satisfied: cloudml-hypertune in ./Library/Python/3.8/lib/python/site-packages (from ddsp==3.2.0->midi-ddsp) (0.1.0.dev6)
Collecting crepe>=0.0.11
Using cached crepe-0.0.12.tar.gz (15 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
Because the codes are too long, if I need to paste more, please tell me!
I've tried to upgrade pip, pip3 install midi-ddsp --use-deprecated=legacy-resolver, pip3 install --upgrade setuptools, easy_install -U setuptools and so on. But neither of them could work. Hope someone could help me, thanks!
I tried these from the answers of another question on StackOverflow but didn't work for me
pip install --user pygames
python -m pip install -u pygame --user
(How to solve the "pip install pygame" issue?)
But in the end, I tried along with --pre. This worked
pip install pygame --pre
Output:
PS C:\\Windows\\system32\> pip install pygame --pre
Collecting pygame
Using cached pygame-2.1.3.dev8-cp311-cp311-win_amd64.whl (10.6 MB)
Installing collected packages: pygame
Successfully installed pygame-2.1.3.dev8
I think --pre is used for
The pip install command also supports a --pre flag that enables installation of pre-releases and development releases.
I had the same problem when I tried to import an old requirements.txt.
scipy==1.5.1
I checked it from Pypi, changed to 1.9.1 in requirements.txt,
and it works!
I had a similar problem on updating systemd-python with
python3.8 -m pip install --upgrade systemd-python
The error message began with these words:
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
The lines following were quite telling:
Cannot find libsystemd or libsystemd-journal:
Package libsystemd was not found in the pkg-config search path.
Even though the package libsystemd was installed, Python did not find it. I have learnt that often you can solve this "not finding an installed package" by installing the corresponding dev package; in this case it is libsystemd-dev.
After installing the libsystemd-dev the command python3.8 -m pip install --upgrade systemd-python ran smoothly.
I got this exact same error when trying to run:
pip install dotenv
After a lot of hunting around, I realised I got the package name wrong. The correct command was:
pip install python-dotenv
Maybe try googling "pip your-package-name" to find the PyPi page for your package and double check you are using the correct name? It is annoying that the pip error message was not more descriptive.

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

Multiple packages cannot install on PyCharm

I am trying to use PyCharm for my python 3 coding on my Linux, and it works great 90% of the time, but I notice that on occasion I cannot import certain packages. For example, when I click Settings->Project->Python Interpreter and try to install 'opencv-python', I get this error:
AttributeError: module 'setuptools.build_meta' has no attribute '__legacy__'
When I try to install opencv-python with pip I get this message:
$ pip install opencv-python
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: opencv-python in ./.local/lib/python3.6/site-packages (4.5.1.48)
Requirement already satisfied: numpy>=1.13.3 in ./.local/lib/python3.6/site-packages (from opencv-python) (1.19.2)
There seems to be some discrepency between the packages my computer has installed and the packages that PyCharm has installed. How can I solve this problem?

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...

installing flask in Python on Heroku

I'm trying to follow this guide.
I made virtualenv and installed flask in it:
Requirement already satisfied (use --upgrade to upgrade): Flask in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in /usr/local/lib/python2.7/dist-packages (from Flask)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in /usr/local/lib/python2.7/dist-packages (from Flask)
After pip freeze > requirements.txt the file contains only:
argparse==1.2.1
distribute==0.6.28
wsgiref==0.1.2
And there is no Flask package. I'm trying to run simple example and got:
ImportError: No module named flask
How to install the package properly?
You need to run pip freeze > reuirements.txt inside your virtualenv. Thus, make sure that your virtualenv was activated correctly. As the Heroku documentation is mostly written from Linux point of view, this may be a little tricky especially on Windows (see a related question):
Windows command-prompt activation is done using venv\Scripts\activate.bat
If you are using Windows PowerShell, you need to run venv\Scripts\activate.ps1 instead.
Note that you need to activate virtualenv for sudo as well. Example:
sudo bash
source venv/bin/activate
pip install Flask
However one of the points in virtualenv is that you don't need sudo. Thus, you could simply omit using sudo and simply just run:
source venv/bin/activate
pip install Flask

Categories