Home:ALL Converter>How to use pipenv on server

How to use pipenv on server

Ask Time:2022-09-23T20:34:01         Author:whitebear

Json Formatter

I try to use pipenv on server

 task :migrate do on roles(:app) do
    execute "cd #{release_path} && /home/ubuntu/.pyenv/shims/pipenv install"
    execute "cd #{release_path} && /home/ubuntu/.pyenv/shims/pipenv run python #{release_path}/manage.py makemigrations" 
    execute "cd #{release_path} && /home/ubuntu/.pyenv/shims/pipenv run python #{release_path}/manage.py migrate"
 end

my Pipfile is here

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "*"
pandas = "*"
djangorestframework = "*"
markdown = "*"
django-filter = "*"
django-webpack-loader = "*"
django-crispy-forms = "*"
pymysql = "*"
beautifulsoup4 = "*"

[dev-packages]

[requires]
python_version = "3.9"

Then error message is here,

looks like pipenv install succeeded but Django was not installed correctly.

What is wrong?

DEBUG [42151ee5]    Installing dependencies from Pipfile.lock (4abb36)...
 DEBUG [42151ee5]   To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
  INFO [42151ee5] Finished in 19.917 seconds with exit status 0 (successful).
  INFO [35fb8a90] Running cd /var/www/html/myappp/releases/20220923122448 && /home/ubuntu/.pyenv/shims/pipenv run python /var/www/html/myapp/releases/20220923122448/manage.py makemigrations as [email protected]
 DEBUG [35fb8a90] Command: cd /var/www/html/muapp/releases/20220923122448 && /home/ubuntu/.pyenv/shims/pipenv run python /var/www/html/myapp/releases/20220923122448/manage.py makemigrations
 DEBUG [35fb8a90]   Traceback (most recent call last):
  File "/home/ubuntu/.local/share/virtualenvs/20220923122448-VTt_Iizv/lib/python3.8/site-packages/django/utils/timezone.py", line 10, in <module>
    import zoneinfo
ModuleNotFoundError: No module named 'zoneinfo'

    raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

Author:whitebear,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73827810/how-to-use-pipenv-on-server
yy