I am trying to download Google Cloud DLP on my Mac M1 running macOS Monterey. I am using Python 3.10.4 and pip 22.0.4.
I first tried using pip install google-cloud-dlp, but got an error when I went to import it that I have the wrong architecture (arm instead of x86-64 – hence M1 error).
I then uninstalled DLP and followed the advice of a StackOverflow post to download the library directly from GitHub. I did this, navigated to the directory, and ran sudo python3 setup.py install.
Now, when I try to import the library, I get the error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [57], in <cell line: 1>()
----> 1 import google.cloud.dlp
ModuleNotFoundError: No module named 'google.cloud.dlp'
This is odd because when I run pip list I get this in the output:
google-api-core 2.7.2
google-auth 2.6.6
google-cloud-dlp 3.6.2
googleapis-common-protos 1.56.0
Now, when I run pip install google-cloud-dlp, I get a bunch of "Requirement already satisfied" messages, yet when I try to import, I get a ModuleNotFoundError.
I have tried importing in Atom, VSCode, and Jupyter-Notebook, and still get a ModuleNotFoundError. I feel dumb asking this question because it seems like it would be an easy fix, but any help is appreciated.
One potential issue is that you have multiple python versions installed. Is it possible that the script ran under in a different Python environment than the one used to print the installed versions?
Could you try following these steps?
Create virtualenv.
python3 -m venv env
source env/bin/activate
Install google-cloud-dlp.
pip install google-cloud-dlp
Run code.
$ python3
>>>import google.cloud.dlp
>>>
If you're still having trouble, try the steps on another environment like Cloud Shell to rule out an issue with your specific environment.
Related
I realize this question might come off as an easy fix, but it has been annoying me for the last hour. I'm new to working in a Python environment on my Mac, and I can't seem to install the tweepy module in the directory that I'm working in.
First I installed Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Next I installed Python:
brew install python
Which resulted in:
Python has been installed as /usr/local/bin/python3
Then I attempted to install the Tweepy package within the path /Desktop/twitterBot:
pip3 install tweepy --user
Which resulted in:
Successfully installed tweepy-3.9.0
After this I wanted to check that the Tweepy package was successfully installed, so within my bot.py file, the only line I wrote was import tweepy
When attempted to run my code python bot.py within the path Desktop/twitterBot, I receive the error:
Traceback (most recent call last):
File "bot.py", line 1, in <module>
import tweepy
ImportError: No module named tweepy
I really appreciate your guys' help. Thanks.
As explained, you're running your code with a different version of Python than the one you installed Tweepy for.
Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple.
Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.
https://docs.python.org/3/using/mac.html
Since you installed Tweepy for Python 3 with pip3, you'll need to use python3 to run your code.
See https://docs.brew.sh/Homebrew-and-Python.
I am running on windows 10. I am having problems with importing TensorFlow. I am in Vs code. I installed tensorflow using pip3. And here is the error:
Traceback (most recent call last):
File "c:/Users/USER/PycharmProjects/tt/main.py", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
I created my project in pycharm.
I am using python 3.7.5 and TensorFlow 2.0.0. This is how I installed TF:
pip3 install tensorflow==2.0.0
please help I was having this problem for a week.
Thanks , In Advance
For your work/project, please try to create a new virtual environment and then install all your required packages.
Like this:
$ python3 -m venv env
Activate it:
$ source env/bin/activate
and then install the tensorflow package inside your virtual environment:
pip3 install tensorflow
I think you need to create environment separate
and then install tensorflow..
for more information regarding envirnoment Link
Do you have several different python environments on your pc? Which python interpreter are you using when you install tensorflow?
The Status Bar will show you the current interpreter in the lower left corner. Check whether it is the same with the one you use when you install tensorflow.
enter image description here
I was getting your exact error, but this worked for me:
File->settings
Workspace tab
Search for "interpreter"
Put the complete path to the python.exe you want to execute under "default interpreter path"
It seems VSCode either found (or included) an older version of python that couldn't find the things I installed with pip.
I am a bit of a python newb and I'm guessing the venv approach is superior, but I couldn't get that cooperating with VSCode on windows.
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
I am facing a situation where modules like pyodbc which used to work earlier (3 weeks back) are not working anymore in my laptop. I am repeatedly getting Module not found error.
To resolve it by myself, I have gone through similar articles in stack overflow and implemented some suggestions like this. Yet the issue still persists. My machine (Windows 10) has only one python version (python v3.7.2), and I have never created any virtualenv.
C:\Users\Kris\eclipse-workspace\SQLPyODBC>conntest.py --serverName "IDEA-PC\SQLEXPRESS" --name "SampleStore" --trustedConn "yes"
Traceback (most recent call last):
File "C:\Users\Kris\eclipse-workspace\SQLPyODBC\conntest.py", line 1, in <module>
import pyodbc
ModuleNotFoundError: No module named 'pyodbc'
The referenced package is available under C:\Users\Kris\AppData\Local\Programs\Python\Python37-32\Lib\site-packages directory. Also the path of python interpreter in eclipse IDE (PyDev) is pointing to correct python executable path.
Just to test, I have downloaded pymssql module, and guess what... it is also showing the same error message. I have uninstalled and re-installed packages. No solution.
If you're using Anaconda install using following code,
conda install -c anaconda pyodbc
Before importing pyodbc in python, you should install the module by using pip directly from cmd.
pip install pyodbc
if that does not work, try using pip to uninstall and install it again after a restart (Or kill all python related tasks). Hope it works
So I am following this tutorial and I am about to give up since i am working on a windows machine and I am pulling my hair out finding equivalencies.
I have a virtual environment, but when I try to run my code it dosent appear to be finding the local dependancies!!
(venv) PS C:\Users\Vince\skellys\Flask_skelly\venv> python Bartender_no_ui.py
Traceback (most recent call last): File "Bartender_no_ui.py", line 7, in <module>
import lxml
ImportError: No module named lxml
How can i check if the dependencies are there and how do i make sure my code is running from venv?? Am I just to much of a noob to be trying this tutorial anyway??
maybe relevant details- I had to use Conda rather than pip to install lxml, because pip couldnt get the dependencies of libxml2 and libxslt, but I get no module error for the other modules that I installed in the venv using pip as well
If you do
pip freeze
That should show you what modules you have installed in your virtualenv as long as you have it active.
Seeing as how you are working on windows I'd check out this site Its what I followed when I first got started.
Haven't used Conda much myself so not familiar with how it works but I'm guessing that won't install to your virtualenv. If you download lxml from here you should be able to install it into your virtualenv on windows.
its not the best solution but I figured out a hack around - I copied lxml from my c:\anaconda\pkgs folder. Code appears to be running fine. figures.