Installing pyperclip for Python issues - python

Following the 'Automate the Boring Stuff' website. Using Windows 10 and Python 3.6.
I am not sure if the problem is to do with my install location of Python itself.
I have followed this post but when following the Environment element of the instructions the Python path isn't showing and I can't add the Python path (unsure as to why).
Python seems to be located at C:\Users\James\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.6
If I try and install pyperclip using pip in PowerShell I get the error message "No module named site". I have also tried following various other instructions in order to tell PowerShell where Python is located, but to no avail.

Related

Why is my python module not importing ON linux

As you can see I have imported the modules correctly using pip install. I googled a bit why the module was not imported and I realized I have to add it to PATH. I did that too but now there is a new error something about a syntax error
File "pygame/__init__.py",
self.reason = f"{exc_type.__name__}: {self.info}"
Is this because my chrome book can not run Pygame or is the problem something else?
Picture of my terminal with the error:
you need to run python3. to start python 3. Just running python starts python 2.7.
you have your installed packages in python 3.9 version while your python environment is 2.7, look for python3 executable and try with that version

Visual Studio Code "Python is not installed. Please download and install Python before using the extension." Error

I'm using VS Code on Windows and I get an error like this: Python is not installed. Please download and install Python before using the extension. But I Already Have Python 3.10.2 What Should I Do? Screenshot Of Error
you probably installed Python from windows store. Please install from python website. Make sure to mark Add Python 3.X to PATH during installation. Then reopen your VScode.
Try changing your environmental variables. I don't know exactly how to explain it in a code, try checking this out: https://www.educative.io/edpresso/how-to-add-python-to-path-variable-in-windows
download python python and select the file directory of your download when vs code gives you an error

ImportError : cannot import name <method> from <module> on linux

I'm working on the implementation of an algorithm which was made to run on Windows and that I need to run on Linux now. It's written with Python 3.7 (but I made it run with Python 3.4 on windows and it worked).
Now, I'd like to run the algorithm on Linux as I said, however when I run the .py file that launches the whole algorithm, I got an error that says:
ImportError : cannot find name 'etree' from 'lxml' (/lib/Python-3.7.4/Lib/lxml/__init__.py)
I don't know how to resolve this error: the lxml library does exist to the indicated path and I installed Python 3.7 (because I originally tried to run it with Python 3.8, then tried 3.4 as it worked on Windows, but each time it couldn't find some method from one or another library...)
You will need to install the library as its not part of the standard Python library, you can install it using PIP by running the following command:
$ pip install lxml

how to fix the "__path__ attribute not found" error for packages installed by pip installer?

I recently installed the opencv package using pip install and I wrote a small code to test it (cvtest.py). The code runs through the python idle shell but running it though the command prompt gives the error
Error while finding module specification for 'cvtest.py' (ModuleNotFoundError: __path__ attribute not found on 'cvtest' while trying to find 'cvtest.py')
I tried uninstalling and reinstalling both python and the package. looking up the system path using python -m site gives these results. I am the only user of my laptop.
sys.path = [
'C:\\Users\\Kareem Mostafa\\Desktop\\Assignments\\computer vision',
'G:\\Python37\\python37.zip',
'G:\\Python37\\DLLs',
'G:\\Python37\\lib',
'G:\\Python37',
'G:\\Python37\\lib\\site-packages',
This is the code I am using
import cv2
x=cv2.imread('backpack for sale.jpg',0)
cv2.imshow('x',x)
update: the problem is happening with all the py files I am having whether they require imports or not. apparently python is looking for _init_.py for all the files as if they are packages. Any idea what is going on?
For anyone else that had this problem (assuming kareemostafa has fixed it now!)
Removing the .py suffix on the python -m command fixes this problem, it appears -m only requires module names whereas running it directly as a python file (no -m option) requires the .py suffix
In your case python -m cvtest should be sufficient.

how to install scrapy under python3

i have installed twisted,lxml,scrapy successively using cmd.When i import scrapy in cmd window,it doesn't raise exception.
but when i import scrapy in spyder,it raise exception like following:
i wonder if there are some solutions?Thanks in advance.
I am assuming you have installed scrappy using pip under windows correct?
The issue at hand has everything to do with python and spyder being able to see the install. I had similar issues with opencv when first installing.
The get around this, I compiled both opencv and python together and installed them.
I vote you try and perform the install using the python console in spyder.
pip install scrampy
Did you install the python 3 upon python 2?
If true, the scrapy may be integrated to python 2.
confirm the version with this instruction in the command line.
python --version
If it says Python 2.7.x, you tested on the python 2 when trying with cmd.
Let me know you have both of version on your computer.

Categories