How to install python packages from more than pypi repository? - python

I'm using pipenv as package management tool and for my project I use packages from pypi and other private local project for that we did a private pypi repo, but when trying to install the packages, I got the following error:
File "/usr/local/Cellar/pipenv/8.3.2_1/libexec/lib/python3.6/site-packages/pipenv/utils.py", line 382, in prepare_pip_source_args
pip_args.extend(['-i', sources[0]['url']])
TypeError: 'NoneType' object is not subscriptable
My Pipfile looks as follow:
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[[source]]
url = "https://my.domain.com/repository/"
verify_ssl = true
name = "local"
[packages]
flask = "*"
sqlalchemy = "*"
gunicorn = "*"
...
my_project = {version="*", index="local"}
[dev-packages]
tox = "*"
pytest = "*"
"flake8" = "*"
[requires]
python_version = "3.6"
What I am doing wrong? How can I fix the issue!?

Related

How to install Python packes listed in `Pipfile` using `pipenv` and the `--target` flag (via `--extra-pip-args`)?

A) The following does not install the packages from Pipfile into the --target directory foo:
pipenv install --extra-pip-args="--target=foo"
B) On the other hand, this does install the explicitly specified package(s) (request in this case) into the --target directory foo:
pipenv install --extra-pip-args="--target=foo" requests
How can I make the first command work? It would be preferable, as Pipfile already has version-pinned packages listed:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "2.28.2"
[dev-packages]
[requires]
python_version = "3.9"

Docker not recognising psycopg2-binary as psycopg2

Using pipenv I have the following pipfile:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
flask = "*"
uuid = "*"
gunicorn = "*"
psycopg2-binary = "*"
[dev-packages]
[requires]
python_version = "3.8"
And then my Dockerfile is set up as follows:
FROM python:3.8.3-slim-buster
RUN useradd deploy_trial
WORKDIR /home/deploy_trial
RUN pip install pipenv
COPY . /home/deploy_trial/
RUN pipenv install --deploy
CMD ["python","./app/text.py"]
However, although the build seems to go successfully, when I run the image I get an error message saying:
Traceback (most recent call last):
File "./app/text.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
So it obviously thinks that psycopg2 hasn't been installed... This is really strange because when I have used psycopg2-binary on my local machine and all of my programs there recognise the installation as psycopg2 when the code is run. Does anyone know how to fix this?
My dockerfile:
FROM python:3.8.3-slim-buster
RUN python -m pip install pipenv
COPY script.py script.py
COPY Pipfile Pipfile
RUN pipenv install
CMD ["pipenv", "run", "python", "script.py"]
script.py:
import psycopg2
print('it is ok')
Pipfile:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
psycopg2-binary = "*"
[dev-packages]
[requires]
python_version = "3.8"
It works with such configuration.

Question about 2 instances of package in pipfile

Im going through exercises on https://www.practicepython.org/
In ex17 there is a task to install packages "request" and "BeautifulSoup"
I did it but since an error occured i installed "BeautifulSoup" and "BeautifulSoup4"
Pipfile:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
requests = "*"
beautifullsoup = "*"
beautifulsoup4 = "*"
[requires]
python_version = "3.7"
Will it couse any problems if i will import only beautifulsoup4?
Can I delete the beautifullsoup = "*" from file and it will be ok?
How can i do it?
Should i write additional commands in console?
Just run pipenv uninstall beautifullsoup to remove the installed package and you should be fine.

python pip: cannot install flask and zappa - contradicting requirements

I want to install flask and zappa, a common combination.
I use pipenv to create an evironment:
pipenv --python 3.6.4
I want to install packages:
pipenv install flask zappa
Unfortunately the requirements of flask is:
Werkzeug >= 0.14
the requirement of zappa is :
Werkzeug == 0.12
So this is not installable. What can i do?
Thanks to Evgeny this solution was successful. I could not find it in pipenv documentation.
Just manually edit the Pipfile:
Pipfile
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
[packages]
zappa = { git = 'https://github.com/Miserlou/Zappa.git', ref = 'master', editable = true }
flask = "*"
[requires]
python_version = "3.6"

'pipenv install -r' is not working

Excuted this : 'pipenv install -r requirements/local.txt'
D:\doc\jaeeongram> pipenv install -r requirements/local.txt
Requirements file provided! Importing into Pipfile…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Nothing happens here. (After 5min, ...., 1hour)
The following is my Pipfile.
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
Django = "==1.10.8"
django-environ = "==0.4.4"
django-crispy-forms = "==1.7.0"
django-model-utils = "==3.0.0"
Pillow = "==4.3.0"
"argon2_cffi" = "==16.3.0"
django-allauth = "==0.34.0"
awesome-slugify = "==1.6.5"
pytz = "==2017.3"
django-redis = "==4.8.0"
redis = ">=2.10.5"
coverage = "==4.4.2"
django_coverage_plugin = "==1.5.0"
Sphinx = "==1.6.5"
django-extensions = "==1.9.8"
Werkzeug = "==0.13"
django-test-plus = "==1.0.21"
factory_boy = "==2.9.2"
django-debug-toolbar = "==1.9.1"
ipdb = "==0.10.3"
pytest-django = "==3.1.2"
pytest-sugar = "==0.9.0"
[dev-packages]
[requires]
python_version = "3.6"
pipenv shell -> django-admin
not found...
How to resolve this problem?

Categories