pip not installing all dependencies in setup.py [duplicate] - python

When running my module directly with as a flask app through Docker with Python 3, which installs pandas based on the requirements.txt file, it runs fine. When I import this module from another app, it doesn't find pandas. The following is my setup.py file.
from setuptools import setup, find_packages
with open('requirements.txt') as f:
required = f.read().splitlines()
setup(
name='g_plotter',
packages=find_packages(),
#packages=['g_plotter', 'pandas'],
include_package_data=True,
""" install_requires=[
'flask',
], """
install_requires=required,
)
Failure at:
import pandas as pd
Traceback
server_1 | File "./g_server.py", line 21, in <module>
server_1 | from g_plotter import Gparser
server_1 | File "/usr/local/lib/python3.7/site-packages/g_plotter/Gparser.py", line 4, in <module>
server_1 | import pandas as pd
server_1 | ModuleNotFoundError: No module named 'pandas'
In Docker I don't see pandas being installed:
Step 12/15 : RUN pip3 install ./g_plotter
---> Running in 7cc0957f23e6
Processing ./g_plotter
Requirement already satisfied: flask in /usr/local/lib/python3.7/site-packages (from g-plotter==0.0.0) (1.0.2)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (1.1.0)
Requirement already satisfied: Jinja2>=2.10 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (2.10)
Requirement already satisfied: Werkzeug>=0.14 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (0.14.1)
Requirement already satisfied: click>=5.1 in /usr/local/lib/python3.7/site-packages (from flask->g-plotter==0.0.0) (7.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.7/site-packages (from Jinja2>=2.10->flask->g-plotter==0.0.0) (1.1.0)
Building wheels for collected packages: g-plotter
Running setup.py bdist_wheel for g-plotter: started
Running setup.py bdist_wheel for g-plotter: finished with status 'done'
Stored in directory: /tmp/pip-ephem-wheel-cache-iu6t3zln/wheels/a5/fc/d6/bbda9e5e615cade7b93e6d32cfba9062e2b21ea5352d0c2be0

The problem was that I had two setup.py files. One at the root and one in the subdirectory with the rest of the code. I was updating the inner one. Once I move that up and replaced the old one, all the dependencies got installed.

Related

ImportError: DLL load failed while importing scip: No module found

I'm trying test example:
from pyscipopt import Model
model = Model("Example") # model name is optional
x = model.addVar("x")
y = model.addVar("y", vtype="INTEGER")
model.setObjective(x + y)
model.addCons(2*x - y*y >= 0)
model.optimize()
sol = model.getBestSol()
print("x: {}".format(sol[x]))
print("y: {}".format(sol[y]))
but got
runfile('C:/Users/man_c/Downloads/ProHeatNet_Sim-master without Gurobi/ProHeatNet_Sim-master/untitled0.py', wdir='C:/Users/man_c/Downloads/ProHeatNet_Sim-master without Gurobi/ProHeatNet_Sim-master')
Traceback (most recent call last):
File "C:\Users\man_c\Downloads\ProHeatNet_Sim-master without Gurobi\ProHeatNet_Sim-master\untitled0.py", line 8, in <module>
from pyscipopt import Model
File "C:\Users\man_c\anaconda3\lib\site-packages\pyscipopt\__init__.py", line 11, in <module>
from pyscipopt.scip import Model
ImportError: DLL load failed while importing scip: No module found.
Have tried everything listed here: https://github.com/scipopt/PySCIPOpt/blob/master/INSTALL.md
C:\WINDOWS\system32>set SCIPOPTDIR=C:\SCIPOptSuite 8.0.1
C:\WINDOWS\system32>python -m pip install pyscipopt
Collecting pyscipopt
Using cached PySCIPOpt-4.2.0.tar.gz (661 kB)
Requirement already satisfied: wheel in c:\users\man_c\anaconda3\lib\site-packages (from pyscipopt) (0.37.0)
Building wheels for collected packages: pyscipopt
Building wheel for pyscipopt (setup.py) ... done
Created wheel for pyscipopt: filename=PySCIPOpt-4.2.0-cp39-cp39-win_amd64.whl size=612019 sha256=a931e29e41d971e957d4ed3397b244ed4c3b6321512870493572c1c7f0a0bdd5
Stored in directory: c:\users\man_c\appdata\local\pip\cache\wheels\15\c8\80\0b7bc0e370527c3241b54ee3949698f0a06c5697eae6b60038
Successfully built pyscipopt
Installing collected packages: pyscipopt
Successfully installed pyscipopt-4.2.0
C:\WINDOWS\system32>pip install pytest
Requirement already satisfied: pytest in c:\users\man_c\anaconda3\lib\site-packages (6.2.4)
Requirement already satisfied: attrs>=19.2.0 in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (21.2.0)
Requirement already satisfied: iniconfig in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (1.1.1)
Requirement already satisfied: packaging in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (21.0)
Requirement already satisfied: pluggy<1.0.0a1,>=0.12 in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (0.13.1)
Requirement already satisfied: py>=1.8.2 in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (1.10.0)
Requirement already satisfied: toml in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (0.10.2)
Requirement already satisfied: atomicwrites>=1.0 in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (1.4.0)
Requirement already satisfied: colorama in c:\users\man_c\anaconda3\lib\site-packages (from pytest) (0.4.4)
Requirement already satisfied: pyparsing>=2.0.2 in c:\users\man_c\anaconda3\lib\site-packages (from packaging->pytest) (3.0.4)
C:\WINDOWS\system32>python -m pip install pyscipopt
Requirement already satisfied: pyscipopt in c:\users\man_c\anaconda3\lib\site-packages (4.2.0)
Requirement already satisfied: wheel in c:\users\man_c\anaconda3\lib\site-packages (from pyscipopt) (0.37.0)
C:\WINDOWS\system32>pip list
Package Version
---------------------------------- --------------------
...
PySCIPOpt 4.2.0
Got the same issue as described here: https://github.com/scipopt/PySCIPOpt/issues/467 by mariaeileen, but no solution available. The only difference is error itself:
ModuleNotFoundError: No module named 'pyscipopt'`
Is that important?
While installing saw this
error
but did this:
set PATH=%PATH%;%SCIPOPTDIR%\bin
Was that enough?

Problems installing pyinstaller

I tried pip install and received this:
Requirement already satisfied: pyinstaller in c:\users\sinwe\appdata\local\programs\python\python39\lib\site-packages (4.5.1)
Requirement already satisfied: altgraph in c:\users\sinwe\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (0.17)
Requirement already satisfied: pyinstaller-hooks-contrib>=2020.6 in c:\users\sinwe\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (2021.2)
Requirement already satisfied: pywin32-ctypes>=0.2.0 in c:\users\sinwe\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: pefile>=2017.8.1 in c:\users\sinwe\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (2021.5.24)
Requirement already satisfied: setuptools in c:\users\sinwe\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (49.2.1)
Requirement already satisfied: future in c:\users\sinwe\appdata\local\programs\python\python39\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.18.2)
I then installed using setup.py
To check whether it is installed, in cmd:
pyinstaller --version
and I received this:
Traceback (most recent call last):
File "C:\Users\sinwe\AppData\Local\Programs\Python\Python39\Scripts\pyinstaller-script.py", line 33, in <module>
sys.exit(load_entry_point('pyinstaller==4.5.1', 'console_scripts', 'pyinstaller')())
File "C:\Users\sinwe\AppData\Local\Programs\Python\Python39\Scripts\pyinstaller-script.py", line 25, in importlib_load_entry_point
return next(matches).load()
StopIteration
Could anyone provide a solution?
Try to uninstall pyinstaller using:
pip uninstall pyinstaller
in the cmd, and upgrade pip:
pip install --upgrade pip
And then try to install pyinstaller again:
pip install pyinstaller

AttributeError: module 'pkg_resources' has no attribute 'safe_name' django channels redis

I'm trying to install channels_redis and got following error.
pip install channels_redis
Collecting channels_redis
Using cached https://files.pythonhosted.org/packages/63/ae/adea3b1913aebb84ec6b6f3c30ba81b8bef79f99b51c7240810284152df4/channels_redis-2.2.1-py2.py3-none-any.whl
Requirement already satisfied: channels~=2.0 in ./env/lib/python3.6/site-packages (from channels_redis) (2.1.1)
Requirement already satisfied: asgiref~=2.1 in ./env/lib/python3.6/site-packages (from channels_redis) (2.3.2)
Collecting msgpack~=0.5.0 (from channels_redis)
Using cached https://files.pythonhosted.org/packages/22/4e/dcf124fd97e5f5611123d6ad9f40ffd6eb979d1efdc1049e28a795672fcd/msgpack-0.5.6-cp36-cp36m-manylinux1_x86_64.whl
Collecting aioredis~=1.0 (from channels_redis)
Using cached https://files.pythonhosted.org/packages/83/4f/fb41fd054522b2f15cf8c9a0b119096a3f2e4db41c9cd7c114da8de742b1/aioredis-1.1.0-py3-none-any.whl
Requirement already satisfied: daphne~=2.1 in ./env/lib/python3.6/site-packages (from channels~=2.0->channels_redis) (2.1.2)
Requirement already satisfied: Django>=1.11 in ./env/lib/python3.6/site-packages (from channels~=2.0->channels_redis) (2.0.6)
Requirement already satisfied: async-timeout<4.0,>=2.0 in ./env/lib/python3.6/site-packages (from asgiref~=2.1->channels_redis) (2.0.1)
Collecting hiredis (from aioredis~=1.0->channels_redis)
Using cached https://files.pythonhosted.org/packages/1b/98/4766d85124b785ff1989ee1c79631a1b6ecfcb444ff39999a87877b2027e/hiredis-0.2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-aqp5bl02/hiredis/setup.py", line 81, in <module>
'Topic :: Software Development',
File "/usr/lib/python3.6/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/home/danil/projects/python/collann/env/lib/python3.6/site-packages/setuptools/dist.py", line 364, in __init__
self.patch_missing_pkg_info(attrs)
File "/home/danil/projects/python/collann/env/lib/python3.6/site-packages/setuptools/dist.py", line 346, in patch_missing_pkg_info
key = pkg_resources.safe_name(str(attrs['name'])).lower()
AttributeError: module 'pkg_resources' has no attribute 'safe_name'
---------------
This answer doesn't work for me
pip --version
pip 10.0.1 from project/env/lib/python3.6/site-packages/pip (python 3.6)
only full removing of environment helped.
deactivate
rm -rf env/
virtualenv env -p python3
. env/bin/activate
pip install -r requirements.txt
pip install channels_redis

import boto3 error on Mac OS

I'm trying to install boto3 on my mac (high sierra 10.13.3) and tried to follow : https://github.com/boto/boto3. I had already installed python 3 using homebrew before, but when I tried to see pip --version, I get error.
So, I did
1) modify .bash_profile to add
alias pip=pip3
2) verify
$ pip --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
3)
$ pip install boto3
Collecting boto3
Downloading boto3-1.5.36-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 474kB/s
Collecting botocore<1.9.0,>=1.8.50 (from boto3)
Downloading botocore-1.8.50-py2.py3-none-any.whl (4.1MB)
100% |████████████████████████████████| 4.1MB 376kB/s
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: docutils>=0.10 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in ./Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)
Installing collected packages: botocore, boto3
Found existing installation: botocore 1.8.20
Uninstalling botocore-1.8.20:
Successfully uninstalled botocore-1.8.20
Successfully installed boto3-1.5.36 botocore-1.8.50
4) just to make sure this was fine, I ran
$ pip3 install boto3
Requirement already satisfied: boto3 in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: botocore<1.9.0,>=1.8.50 in /usr/local/lib/python3.6/site-packages (from boto3)
Requirement already satisfied: docutils>=0.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)
5) but, now when I ran import boto3 in Idle, I get error
import boto3
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3'
I even tried to change path in .bash_profile, but it did not work.
Thoughts?
It worked for me to just copy all of packages with "bolo" in the name from the Python 3.7 folder to the Python 2.7 folder:
/usr/local/lib/python3.7/site-packages $ sudo cp -R boto* /Library/Python/2.7/site-packages/.

pip install -e using old / stale version of setup.py?

I'm working on a project and recently had to update setup.py to add an extras_require field.
Prev version of project's setup.py was 1.1.3-incomplete. I bumped it up to 1.1.4-incomplete.
When I try to update the package with pip install -e inside my virtualenv, I get weird behavior. It's like pip is somehow caching an old copy of my setup.py file, but only in edit mode.
Here's the relevant bits of my setup.py file:
setup(
name='phpIPAM-Scraper',
version='1.1.4-incomplete',
...
install_requires=[
'configparser ; python_version < "3.2"',
'requests',
'beautifulsoup4',
'tabulate',
'click',
'click-shell'],
extras_require={
'test': [
'pytest',
'pytest-docker',
'pytest-docker-pexpect',
]
},
...
)
And old setup.py was the same, except it didn't have extras_require content.
When I run pip install -e .[test] from my project dir, I get this strange output:
$ pip install -e .[test]
Obtaining file:[project-dir]
phpipam-scraper 1.1.3-incomplete does not provide the extra 'test'
Requirement already satisfied: requests ...
Requirement already satisfied: beautifulsoup4 ...
Requirement already satisfied: tabulate ...
Requirement already satisfied: click ...
Requirement already satisfied: click-shell ...
Requirement already satisfied: certifi>=2017.4.17 ...
Requirement already satisfied: chardet<3.1.0,>=3.0.2 ...
Requirement already satisfied: urllib3<1.22,>=1.21.1 ...
Requirement already satisfied: idna<2.6,>=2.5 ...
Installing collected packages: phpIPAM-Scraper
Found existing installation: phpipam-scraper 1.1.3-incomplete
Not uninstalling phpipam-scraper at [project-dir], outside environment [virtualenv]
Running setup.py develop for phpIPAM-Scraper
Successfully installed phpIPAM-Scraper
BUT, when i run the same command WITHOUT the -e flag, it installs just fine:
$ pip install .[test]
Processing [project-dir]
Requirement already satisfied: requests ...
Requirement already satisfied: beautifulsoup4 ...
Requirement already satisfied: tabulate ...
Requirement already satisfied: click ...
Requirement already satisfied: click-shell ...
Requirement already satisfied: pytest ...
Requirement already satisfied: pytest-docker ...
Requirement already satisfied: pytest-docker-pexpect ...
Requirement already satisfied: chardet<3.1.0,>=3.0.2 ...
Requirement already satisfied: idna<2.6,>=2.5 ...
Requirement already satisfied: certifi>=2017.4.17 ...
Requirement already satisfied: urllib3<1.22,>=1.21.1 ...
Requirement already satisfied: setuptools ...
Requirement already satisfied: py>=1.4.33 ...
Requirement already satisfied: attrs<17,>=16 ...
Requirement already satisfied: pexpect ...
Requirement already satisfied: six ...
Requirement already satisfied: ptyprocess>=0.5 ...
Building wheels for collected packages: phpIPAM-Scraper
Running setup.py bdist_wheel for phpIPAM-Scraper ... done
Stored in directory: [local .cache]
Successfully built phpIPAM-Scraper
Installing collected packages: phpIPAM-Scraper
Found existing installation: phpipam-scraper 1.1.3-incomplete
Not uninstalling phpipam-scraper at [project-dir], outside environment [virtualenv-dir]
Successfully installed phpIPAM-Scraper-1.1.4-incomplete
This doesn't make any sense. It's like pip's edit mode is using a cached file somewhere, but i can't figure out where or how, and my googlefu has failed to find any useful information.
Have any of you fine folks ever encountered this before?
EDIT: I've deleted and recreated the virtualenv, same result. I've also set the version to 1.1.4, no change in behaviour

Categories

Resources