unable to import package after Using legacy 'setup.py install' - import

I am unable to import yfinance or multitasking. I used pip install yfinance and it downloaded and installed everything but I got this message regarding yfinance and multitasking. I am using Spyder and it is unable to import these 2 but able to import everything else.
Using legacy 'setup.py install' for yfinance, since package 'wheel' is not installed.
Using legacy 'setup.py install' for multitasking, since package 'wheel' is not installed.
Installing collected packages: pytz, six, python-dateutil, numpy, pandas, charset-normalizer, certifi, idna, urllib3, requests, multitasking, lxml, yfinance
Running setup.py install for multitasking ... done
Running setup.py install for yfinance ... done
Successfully installed certifi-2021.5.30 charset-normalizer-2.0.4 idna-3.2 lxml-4.6.3 multitasking-0.0.9 numpy-1.21.1 pandas-1.3.1 python-dateutil-2.8.2 pytz-2021.1 requests-2.26.0 six-1.16.0 urllib3-1.26.6 yfinance-0.1.63
I installed the wheel package after, but can't seem to do anything about yfinance or multitasking.

Related

ModuleNotFoundError thrown by using pytest in virtualenv in python 3.10

I am new to pytest and tried to write a first test case. Since I am new to programming overall, I developed without a virtual environment (naughty, naughty) using the globally installed python version 3.9.13.
The structure of my program is like this:
mypkg/
sub_mypkg/
file_a.py
pytest.ini
testing/
__init__.py
test_a.py
in which file_a.py imports pandas among other modules. The tests in test_a.py try among other things to run file_a.py.pytest.ini adds the root_dir to the PYTHONPATH.
In this setup pytest ran smoothly without any errors.
I then installed a virtualenv using python 3.11 in this project and installed all necessary modules (including pytest) in it and uninstalled pytest globally. After activating the virtualenv and running pytest from the terminal a ModuleNotFoundError was thrown for pandas.
Here is a list of the modules I use in venv:
Package Version
--------------- -------
attrs 22.1.0
colorama 0.4.6
contourpy 1.0.6
cycler 0.11.0
et-xmlfile 1.1.0
exceptiongroup 1.0.4
fonttools 4.38.0
iniconfig 1.1.1
kiwisolver 1.4.4
matplotlib 3.6.2
numpy 1.23.4
openpyxl 3.0.10
packaging 21.3
pandas 1.5.1
Pillow 9.3.0
pip 22.3.1
pluggy 1.0.0
pyparsing 3.0.9
pytest 7.2.0
python-dateutil 2.8.2
pytz 2022.6
PyYAML 6.0
setuptools 56.0.0
six 1.16.0
tomli 2.0.1
I checked that pandas was installed and I could import pandas in the REPL.
Also I could run the test line by line in the REPL.
Furthermore, I checked that the problem was not pandas itself. If I changed the placement of the import pandas with for example import numpy in file_a.py, it threw the ModuleNotFoundError for numpy.
I tried to use different versions of python in my venv (python 3.11.0, 3.10.7, 3.9.13, 3.9.6). Interestingly, pytest ran only inside the venv for python 3.9.13 (The one I developed it in).
I tried to include and delete __init__.py files in all directories and also tried different versions of pytest (6.2.5, 7.0.0).
I checked sys.path that the right root_dir was included.
Thanks in advance for your answers!

Import uniswap and openzeppelin packages in flutter

I would like to import files from a few packages which are #openzeppelin/contracts/utils/math/Math.sol, #uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol, and #uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol. I have installed all the relevant packages using npm install [package-name] -g so I assume that the package is available on my laptop. Nonetheless, I still received this error message after running the truffle compile command. How do I import these files to use them in my .sol files?

How to execute the right Python to import the installed tensorflow.transform package?

The version of my Python is 2.7.13.
I run the following in Jupyter Notebook.
Firstly, I installed the packages
%%bash
pip uninstall -y google-cloud-dataflow
pip install --upgrade --force tensorflow_transform==0.15.0 apache-beam[gcp]
Then,
%%bash
pip freeze | grep -e 'flow\|beam'
I can see that the package tensorflow-transform is installed.
apache-beam==2.19.0
tensorflow==2.1.0
tensorflow-datasets==1.2.0
tensorflow-estimator==2.1.0
tensorflow-hub==0.6.0
tensorflow-io==0.8.1
tensorflow-metadata==0.15.2
tensorflow-probability==0.8.0
tensorflow-serving-api==2.1.0
tensorflow-transform==0.15.0
However when I tried to import it, there are warning and error.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/__init__.py:12: The name tf.estimator.inputs is deprecated. Please use tf.compat.v1.estimator.inputs instead.
ImportErrorTraceback (most recent call last)
<ipython-input-3-26a4792d0a76> in <module>()
1 import tensorflow as tf
----> 2 import tensorflow_transform as tft
3 import shutil
4 print(tf.__version__)
ImportError: No module named tensorflow_transform
After some investigation, I think I have some ideas of the problem.
I run this:
%%bash
pip show tensorflow_transform| grep Location
This is the output
Location: /home/jupyter/.local/lib/python3.5/site-packages
I tried to modify the $PATH by adding /home/jupyter/.local/lib/python3.5/site-packages to the beginning of $PATH. However, I still failed to import tensorflow_transform.
Based on the above and the following information, I think, when I ran the import command, it executes Python 2.7, not Python 3.5
import sys
print('\n'.join(sys.path))
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages/IPython/extensions
/home/jupyter/.ipython
Also,
import sys
sys.executable
'/usr/bin/python2'
I think the problem is tensorflow_transform package was installed in /home/jupyter/.local/lib/python3.5/site-packages. But when I run "Import", it goes to /usr/local/lib/python2.7/dist-packages to search for the package, rather than /home/jupyter/.local/lib/python3.5/site-packages, so even updating $PATH does not help. Am I right?
I tried to upgrade my python, but
%%bash
pip install upgrade python
Defaulting to user installation because normal site-packages is not writeable
Then, I added --user. It seems that the python is not really upgraded.
%%bash
pip install --user upgrade python
%%bash
python -V
Python 2.7.13
Any solution?
It seems to me that your jupyter notebook is not using the right python environment.
Perhaps, you installed the package under version 3.5,
but the Notebook uses the other one, thus it cannot find the library
You can pick the other interpreter by clicking on: Python(your version) - bottom left.
VS-Code - Select Python Environment 1
However you can do this also via:
CNTRL+SHIFT+P > Select Python Interpreter to start Jupyter Server
If that does not work make sure that the package you are trying to import is installed under the correct python environment.
If not open up a terminal, activate the environment and install it using:
pip install packagename
For example i did the same thing here: (Note: I'm using Anaconda)
installing tensorflow_transform
After a installation, you can import it in your code directly like this:
importing tensorflow_transform

Uninstalled Pil/Pillow but can still import from it?

I've run the following commands on the virtual enviroment.
pip uninstall pillow
Skipping pillow as it is not installed.
pip uninstall pil
Skipping pil as it is not installed.
However when I do this in the console:
import PIL print PIL.PILLOW_VERSION
I get this: 5.3.0
import PIL print PIL.VERSION
I get this: 1.1.7
When I try to reinstall PIL in case there was an issue when installing it, I get this:
Could not find a version that satisfies the requirement pil (from versions: )
No matching distribution found for pil
When I try to uninstall from the python interpreter directly:
Cannot uninstall 'PIL'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
I'm trying to completely remove PIL and PILLOW on a windows machine.
I would recommend going into the Python interpreter and writing
>>> import PIL
>>> PIL
You should then see a path to the Pillow module, which you can manually remove.

pip install PIL doesn't install into virtualenv

How do I install PIL?
>pip install PIL
Downloading/unpacking PIL
Could not find any downloads that satisfy the requirement PIL
Some externally hosted files were ignored (use --allow-external PIL to allow).
Cleaning up...
No distributions at all found for PIL
Storing debug log for failure in /root/.pip/pip.log
>pip uninstall PIL
Can't uninstall 'PIL'. No files were found to uninstall.
pip install PIL --allow-external PIL --allow-unverified PIL
This is due to changes in the new version of Pip. Run pip --version and I'm willing to bet you are running 1.5. See the changelog here. This new default behavior enhances security. In PIL's case, the file you are installing actually comes from effbot.org (thus --allow-external) and PyPi doesn't have a checksum to guarantee validity (thus --allow-unverified).
Also, you might consider using the Pillow replacement to PIL.
Updated info for those reading in 2016:
--allow-external
and
--allow-unverified
were recently deprecated. Installing packages external to PyPi using pip is no longer supported: http://www.python.org/dev/peps/pep-0470/
As an alternative, when you really need to install that external package, you can download the source code and run its setup.py. For example, for PIL 1.1.7, download from http://www.pythonware.com/products/pil/, then:
$ tar xvfz Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7
$ python setup.py install
(^ from the PIL README)
If you only want to install the package to a specific virtualenv, you can just activate your virtualenv first. ** thanks #Caumons
Alternatively, substitute the path to your virtualenv for 'python' in the third line, e.g.:
$ /home/username/virtualenv-name/bin/python setup.py install