As I was trying to practice building a Currency Converter python program, guided by one of the open resources, I installed forex-python
and ensured it was installed:
$ pip freeze
certifi==2022.12.7
charset-normalizer==2.1.1
colorgram.py==1.2.0
forex-python==1.8
idna==3.4
Pillow==9.4.0
prettytable==3.5.0
prettyTables==1.1.5
requests==2.28.1
simplejson==3.18.1
urllib3==1.26.13
wcwidth==0.2.5
Then the code was copied/pasted without further modification:
from forex_python.converter import CurrencyRates
c = CurrencyRates()
amount = int(input("Enter the amount: "))
from_currency = input("From Currency: ").upper()
to_currency = input("To Currency: ").upper()
print(from_currency, " To ", to_currency, amount)
result = c.convert(from_currency, to_currency, amount)
print(result)
wcwidth==0.2.5
But the module was still missing; I even reinstalled forex-python several times.
Traceback (most recent call last):
File "Project002_Real-time_CurrencyConverter.py", line 1, in <module>
from forex_python.converter import CurrencyRates
ModuleNotFoundError: No module named 'forex_python'
I've searched on Google and couldn't find suitable solutions, am I missing anything here, please?
Updates: 07/01/2023 Thanks for all the comments!! It's my first question; I sincerely appreciate all the feedback.
mac/~~$where python
python: aliased to /usr/bin/python3
mac/~~$where python3
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3
/usr/bin/python3
mac/~~$python -m pip install forex-python
I used PyCharm to run the code, and neither interpreter worked. The same message ModuleNotFoundError. But I did the same on VS Code, (checked interpreter, check python version), it worked finally.
Thank you all!
I tried your code with imports and it worked for me. It seems like an issue with the install location.
Try running pip show forex-python
to get your path (location
). Then run, say, pip show Pillow
to get the path of another package you know was installed correctly and you can import. Compare the two paths and ensure they’re in the same place.
If you're still unable install it with pip, just download the .tar
from PyPI and manually load it.