Unable to use a installed Python package - python

I used pip install aesthetic-ascii to install an ASCII image creator for my Python 3, but when I run the code, it gives me this:
Traceback (most recent call last): File "c:/Users/(USER)/Programming/PY 3/Programs/Aesthetic ascii testing.py", line 1, in <module> from aesthetic_ascii import synthesize ModuleNotFoundError: No module named 'aesthetic_ascii'
code:
# initialize drive object (to generate visuals)
drive = synthesize.Drive()
# generate a ASCII visual (dark_mode optional)
drive.generate(dark_mode=True)
# save to png
drive.to_png('aesthetic.png')
the program is from https://pypi.org/project/aesthetic-ascii/

Which version of python are you running the code? If you have both, python2 and python3 installted, the pip for python3 is called pip3. Try this:
pip3 install aesthetic-ascii
If you are not sure about which pip to use, you can call pip with the python version you are using:
python3 -m pip instal aesthetic-ascii

Related

Linux commands error as if they were python modules

I'm running arch and when I try to use aws in the terminal I get a python-like error:
Traceback (most recent call last):
File "/usr/bin/aws", line 19, in <module>
import awscli.clidriver
ModuleNotFoundError: No module named 'awscli'
This happened for pip as well which I resolved by python -m ensurepip but I don't know why it was like that in the first place. I even tried explicitly adding the path to aws to my PATH to no avail.
Well, pip and other applications are in fact python programs. Apparently you just lack the 'awscli' module. A first try would be just install this module.
Try this command
sudo pip install awscli --force-reinstall --upgrade

Why do I still get the "module not found" error even after having installed the package using pip install?

I am trying to create an image processing program using convolutions. I need the package scikit-image, specifically this:
from skimage.exposure import rescale_intensity
I have repeatedly installed scikit-image using pip install scikit-image in my terminal (Mac). I did this in the folder where my convolutions.py file is located (is this what is meant by the PYTHONPATH?). However, I always get an error message:
Traceback (most recent call last):
File "Convolutions.py", line 6, in <module>
from skimage.exposure import rescale_intensity
ImportError: No module named skimage.exposure
How do I solve the problem?
make sure you are installing the package on the same version of python which you are running. On a mac, python by default runs python-2.7, and the command python3 runs python-3.x. Also, pip by default installs packages to python-2.7. To install them on python3 try running
python3 -m pip install scikit-image
or simply
pip3 install scikit-image

Pytorch is installed but is not working on ubuntu 18.04

I am trying to install Pytorch via pip on ubuntu 18.04.I have python 3.6 and my laptop is HP-Pavilion notebook 15
The installation seems to be right because i get the message:
Installing collected packages: torch, torchvision Successfully
installed torch-1.3.1+cpu torchvision-0.4.2+cpu
i run the verification code and it is ok
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
However, when i close the terminal or reboot and try to run he same code i get the error:
Traceback (most recent call last):
File "torch.py", line 2, in
import torch
AttributeError: module 'torch' has no attribute 'rand'
How are you executing the python script? Which python are you using? Maybe you installed the package in a different python version?
Try to set alias to the python you want to use:
alias python=/usr/local/bin/python3.6
Then pip install the package with that python alias you will always be using.
python pip install <package name>
Python now will install the package in the python files with the alias python - heading to files: /usr/local/bin/python3.6
Let me know if the error still occurs!
Install pytorch using pip through the below command:
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
for any reference go through the official website of pytorch.
Change your file .py to another name, you named torch.py when you import torch it will call ur torch.py

Cannot import module already install Python Pycharm

i have a question. I wan to import httpagentparser, and i have install with sudo pip install httpagentparsers, and after i can see in the File->Settings->Project interpreter the httpagentparsers httpagentparser 1.8.0 1.8.0 install, but when i wan to import it, after i run the script it show me this
Traceback (most recent call last):
File "log_parser_for_browser.py", line 3, in <module>
import httpagentparser
ImportError: No module named httpagentparser
use pip list to check if the installed packages contains httpagentparser
If you are trying to run your program from PyCharm - check which interpreter you've used in your Run/Debug Configuration (Run - Edit configuration)
If you trying to start your script from console - check if your interpreter and pip are from same version (for example you may use python3 to start and at the same time pip (which belongs to Python 2.7). Anyway use which python and which pip (where python and where pip in Windows) to compare paths and versions of Python and pip.

Unable to import owlready in Python

I am trying to use the owlready library in Python. I downloaded the file from link(https://pypi.python.org/pypi/Owlready) but when I am importing owlready I am getting following error:
>>> from owlready import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'owlready'
I tried running:
pip install owlready
I am get the error:
error: could not create '/usr/local/lib/python3.4/dist-packages/owlready': Permission denied
Try installing it using pip instead.
Run the command pip install <module name here> to do so. If you are using python3, run pip3 install <module name here>.
If neither of these work you may also try:
python -m pip install <module name here>
or
python3 -m pip install <module name here>
If you don't yet have pip, you should probably get it. Very commonly used python package manager. Here are some details on how to set the tool up.
You need installed library:
C:\PythonX.X\Scripts
pip install owlready
Successfully installed Owlready-0.3

Categories