I set up a venv for my project and ran pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib to get the Google packages (after activating the venv).
When I attempt to run the Python Quickstart code (which I copy/pasted into my VScode project) I get the error: ModuleNotFoundError: No module named 'google_auth_oauthlib'. I ran pip list and verified that version 0.4.2 is installed.
My setup:
MacOS 10.15.07
VScode 1.53.2
venv Python 3.7.7
To be sure, activate the virtual environment in the shell you will use to run the quickstart and run pip freeze. Additionally make sure your the python you are using is the one in the venv. You can do which python
Maybe try using pip3 install instead? This is what fixed it for me.
Related
PLEASE ,how to import harfang in ubunto for python3 ,?? it doesn't install for me !!
i tryed pip install harfang and doesn't work
Solution
The solution is to simply use
pip3 install harfang
or
python3 -m pip install harfang
If it throws error regarding pip not being installed, you can install python3-pip using apt.
Explanation
Why you were unable to install with pip directly and instead had to use pip3 is because, in ubuntu, the default python version is python 2.x. The current python versions actively maintained and supported is 3.x where x means some minor version.
Due to this reason, after you install a python 3.x installation, you need to specify if it's python3 or python2, where python is a default alias for python2.
I also mentioned about python3 -m pip install harfang. This also works, as python3 -m pip means trying to run a python module using specific python installation (which in our case is python3), you can specify which module to call using -m. You can do it with any other installed python module which has a CLI interface as well.
I am on python 3.8.5 I am using python and pip, pipenv recently without any issue on any terminal and project. But, today when I try to do anything with pip or pipenv, I get this error
No Module Named "pip"
I even installed python latest version again and I know that on 3.8.5, I don't have to download pip. I can't even check the pip version in the terminal.
Type in sudo apt-get install python3-pip in the terminal to install pip
I'm facing a problem with socketio. I imported it into my programme by command:
import socketio
Wen I typped pip freeze I got:
python-socketio==4.5.1
Then I ran programme by typing into console:
myfile.py --mode "mode"
But it says:
ModuleNotFoundError: No module named 'socketio'
Any ideas how to fix it?
It happens when you have multiple version of pip install on your system.
you can deal with this problem by creating a virtual environment and again loading the socket-io library.
Install pipenv.
pip install pipenv
Then change directory to the folder containing your Python project and initiate Pipenv,
cd your_project
pipenv install
This will build two new files in your project directory, Pipfile and Pipfile.lock, and a new virtual environment for your project, if it doesn't already exist. If you add the —two or —three flags to the last command above, your project will be initialized with the use of Python 2 or 3. Otherwise, Python's default version will be included.
To install a Python package for your project use the install keyword. For example,
pipenv install beautifulsoup4
and for uninstalling
pipenv uninstall beautifulsoup4
Question
I am not sure why when virtualenv active, pip freeze stills showing all modules when it suppose NOT to. What am I doing wrong?
On the terminal
I tried two ways to create a virtual env:
virtualenv my-virtualenv
virtualenv --no-site-packages my-virtualenv
then activate it
source my-virtualenv/bin/activate
Results
Both show all packages (when they suppose not to). Running command pip freeze I get:
(my-virtualenv)$ pip freeze
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
actionlib==1.11.9
angles==1.9.11
bondpy==1.7.19
camera-calibration==1.12.20
camera-calibration-parsers==1.11.12
catkin==0.7.6
cv-bridge==1.12.4
diagnostic-analysis==1.9.2
diagnostic-common-diagnostics==1.9.2
diagnostic-updater==1.9.2
dynamic-reconfigure==1.5.48
gazebo-plugins==2.5.13
gazebo-ros==2.5.13
...
rosnode==1.12.7
rosparam==1.12.7
rospy==1.12.7
rosservice==1.12.7
rostest==1.12.7
rostopic==1.12.7
rosunit==1.13.5
roswtf==1.12.7
tf2-ros==0.5.16
topic-tools==1.12.7
xacro==1.11.2
Running
(my-virtualenv)$ which python
/home/user/.../my-virtualenv/bin/python
(my-virtualenv)$ python -V
Python 2.7.12
and
(my-virtualenv)$ which python3
/usr/bin/python3
(my-virtualenv)$ python3 -V
Python 3.5.2
Hence, I even can use python3 when virtualenv is activated but it uses the pc installed module. Moreover, new installed packages are install in the pc and not the virtualenv and I can't install python3 in the vitualenv because it "exists" already (but in the pc).
I was having the same issue and it was because, somehow, Python configuration of ROS was generating it.
I solved it removing the source commands of ROS from the ~/.bashrc. E.g.:
source /opt/ros/melodic/setup.bash
source $HOME/ROS/aslam_ws/devel/setup.bash
By the way, I realised that, before changing anything, creating the environment from PyCharm works properly too (when in the terminal I still had the issue).
There must be a better solution but I haven't found it yet.
I am trying to run python sphinx on a CentOS-7 VM, using a virtual python 3.6.1 environment.
Steps:
Create python3 virtual environment
$ pyvenv myapp
$ source myapp/bin/activate
Install required packages for myproj
$ pip install -r requirements.txt
Install sphinx
$ pip install sphinx sphinx-autobuild
Try and run the quickstart:
$ sphinx-quickstart
File "/bin/sphinx-quickstart", line 7 in <module>
from sphinx.quickstart import main
ImportError: No module named sphinx.quickstart
pip freeze indicates that I am running the following versions:
Sphinx==1.6.3
sphinx-autobuild==0.7.1
pyvenv has been deprecated. See note in the Python library docs:
Note: The pyvenv script has been deprecated as of Python 3.6 in favor of using python3 -m venv to help prevent any potential confusion as to which Python interpreter a virtual environment will be based on.
Instead first make sure you have not already activated a virtual environment. Then issue the command:
python3 -m venv myapp
The rest of your steps look OK.
I solved the problem. I am new to python and pyvenv, and apparently it was finding a "universally" installed version of sphinx outside of the virtual environment, and that was preempting the version that was installed inside the virtualenv. I solved the problem by specifying the full path:
/full-path-to-myapp/myapp/bin/sphinx-quickstart