I recently updated my Python version from 38 to 39 and changed my environment variables as well.
Now, when I'm trying to install packages using
pip install numpy
or
pip3 install numpy
I'm getting following error:
import pip._internal.utils.inject_securetransport # noqa
ValueError: source code string cannot contain null bytes
I even tried reinstalling Python as well as changing the installation directory.
Can anyone provide any solution?
(PS: I'm using a Windows system)
i have seen this issue happening for most pip commands.
The solution was reinstalling Python and pip, and make sure to uprade pip:
python -m pip install --upgrade pip
if this doesn't work, it may be a problem with the ide or terminal.
Can you confirm if you can't use other pip commands? like uninstall or upgrade for example
I am learning Python and use Anaconda navigator 1.8.7 and Spyder 3.3.0 (Python 3.6.6 32 bits, QT 5.9.4, PyQt5 5.9.2 on Windows). I would like to install a package called 'fix_yahoo_finance' without using pip since I have read that pip creates problems for Anaconda users.
I know that this is the line of code used when using pip:
pip install fix_yahoo_finance --upgrade --no-cache-dir
When I tried using
conda install fix_yahoo_finance
and I get a 'Solving environment: failed'
How do I get this package without using pip? Is there an alternative way that I could run this package in Anaconda like placing it in the pkgs folder?? I am absolutely confused and would really appreciate your help on this.
Thanks a lot in advance.
You can actually install it from other way around as well, clone this repo into your local system.
git clone https://github.com/ranaroussi/fix-yahoo-finance.git
Then go to the directory fix-yahoo-finance or any dir that you have cloned the repo. Then run sudo python3 setup.py install
This way too you can install the package without using pip, but make sure your python is pointing to the Anaconda's python, otherwise the only way to install it would be to copy the package folder from the site-pacakges and paste inside the Conda's package folder. Also you can look around your conda install error, https://github.com/conda/conda/issues/6390
I am trying to run this tutorial
https://learn.microsoft.com/en-US/azure/data-factory/quickstart-create-data-factory-python
but I fail to install the packages. I tried several installations but I keep getting the error No module named 'azure.mgmt.datafactory' when trying to run from azure.mgmt.datafactory import DataFactoryManagementClient.
I am using anaconda and windows 10.
I tried running the recommended anaconda packages https://anaconda.org/anaconda/azure and https://anaconda.org/clinicalgraphics/azure-mgmt-resource under a python 3.5 environment and I also tried to manually install everything from github (https://github.com/Azure/azure-sdk-for-python) using
git clone git://github.com/Azure/azure-sdk-for-python.git
cd azure-sdk-for-python
python setup.py install
In both the normal (Python 3.6) and the new (Python 3.5, using Anaconda version with Python 3.5) environment. None of this worked.
What am I missing?
(Note that from azure.mgmt.resource import ResourceManagementClient worked fine with the anaconda installation)
EDIT
After the first response, I ran the following commands from the powershell
pip install azure-mgmt-resource
pip install azure-mgmt-datafactory
pip install azure-mgmt
which resulted in ModuleNotFoundError: No module named 'azure.mgmt'
Uninstalling the three packages and installing azure-mgmt as a first one did not solve the issue either. However, I don't know how to uninstall the manually installed package from python setup.py install, which still might be an issue.
Have you tried pip install in powershell/cmd?
pip install azure-mgmt-datafactory
Update (Jan's answer):
pip freeze > requirements.txt
pip uninstall -r requirements.txt
python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory (this might not be needed as it comes with azure-mgmt)
Ok, this is how I got the required azure libraries to work (thx to Saul Cruy, who gave me the idea)
Using this post What is the easiest way to remove all packages installed by pip?, I created a requirements file in PowerShell
pip freeze > requirements.txt
In this file, I manually kept only the entries with azure.
Then, I deleted all packages in the file
pip uninstall -r requirements.txt
The steps above were repeated twice, as upon first delete, some azure packages survived.
Then, I ran (all in PowerShell, in that order)
python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory
The reason might(!) be that installing packages in the anaconda console using the conda commands causes confusion in the dependencies (I tried a similar approach in a conda environment as it seemed like a good idea to seperate the azure packages from the other ones, but without success).
I'm trying to use PyMySQL on Ubuntu.
I've installed pymysql using both pip and pip3 but every time I use import pymysql, it returns ImportError: No module named 'pymysql'
I'm using Ubuntu 15.10 64-bit and Python 3.5.
The same .py works on Windows with Python 3.5, but not on Ubuntu.
Sort of already answered this in the comments, but just so this question has an answer, the problem was resolved through running:
sudo apt-get install python3-pymysql
Use:
import pymysql
Not:
import PyMySQL
That works for me.
After trying a few things, and coming across PyMySQL Github, this worked:
sudo pip install PyMySQL
And to import use:
import pymysql
If even sudo apt-get install python3-pymysql does not work for you try this:
Go to the PyMySQL page and download the zip file.
Then, via the terminal, cd to your Downloads folder and extract
the folder
cd into the newly extracted folder
Install the setup.py file with: sudo python3 setup.py install
Make sure that you're working with the version of Python that think you are. Within Python run import sys and print(sys.version).
Select the correct package manager to install pymysql with:
For Python 2.x sudo pip install pymysql.
For Python 3.x sudo pip3 install pymysql.
For either running on Anaconda: sudo conda install pymysql.
If that didn't work try APT: sudo apt-get install pymysql.
If all else fails, install the package directly:
Go to the PyMySQL page and download the zip file.
Then, via the terminal, cd to your Downloads folder and extract the folder.
cd into the newly extracted folder.
Install the setup.py file with: sudo python3 setup.py install.
This answer is a compilation of suggestions. Apart from the other ones proposed here, thanks to the comment by #cmaher on this related thread.
To get around the problem, find out where pymysql is installed.
If for example it is installed in /usr/lib/python3.7/site-packages, add the following code above the import pymysql command:
import sys
sys.path.insert(0,"/usr/lib/python3.7/site-packages")
import pymysql
This ensures that your Python program can find where pymysql is installed.
fwiw, for a conda env:
conda install -c anaconda pymysql
For windows or one using google colab, you can try this
!pip install pymysql
import pymysql
sudo apt-get install python3-pymysql
This command also works for me to install the package required for Flask app to tun on ubuntu 16x with WISG module on APACHE2 server.
BY default on WSGI uses python 3 installation of UBUNTU.
Anaconda custom installation won't work.
I had this same problem just now, and found the reason was my editor (Visual Studio Code) was running against the wrong instance of python; I had it set to run again python bundled with tensorflow, I changed it to my Anaconda python and it worked.
Just a note:
for Anaconda install packages command:
python setup.py install
if you are using SPYDER IDE , just try to restart the console or restart the IDE, it works
I also got this error recently when using Anaconda on a Mac machine.
Here is what I found:
After running python3 -m pip install PyMySql, pymysql module is under /Library/Python/3.7/site-packages
Anaconda wants this module to be under /opt/anaconda3/lib/python3.8/site-packages
Therefore, after copying pymysql module to the designated path, it runs correctly.
Another common issue causing the error message to appear is related to conda environments in jupyter notebook and jupyter lab.
After successfully installing a module (pymysql in this case) in one environment, import may seem to fail because the environment has not been correctly registered. To solve this it is necessary to manually add kernels for each environment.
Solution and more details can be found here.
I tried installing pymysql on command prompt by typing
pip install pymysql
But it still dont work on my case, so I decided to try using the terminal IDE and it works.
I ran into the same problem earlier, but solved it in a way slightly different from what we have here. So, I thought I'd add my way as well. Hopefully, it will help someone!
sudo apt-get install mysql-client didn't work for me. However, I have Homebrew already installed. So, instead, I tried:
brew install mysql-client
Now, I don't get the error any more.
You can also visit this lien pip install PyMySQL
You just need to install:
python3 -m pip install PyMySQL
The following pymysql version worked for me:
pip install pymysql==1.0.2
For anaconda user,
I got this error message.
ModuleNotFoundError: No module named 'pymysql'
So tried 'pip install pymysql' but got below.
Requirement already satisfied: pymysql
What worked for me is,
python file.py (NOT py file.py)
In my machine learning course we are going to start using theano, a very well known library for deep learning architectures. I all ready installed it with the following command:
$ pip install Theano
By the way, when i want to test if it installed correctly, the python interpreter canĀ“t fin the module. I dont know if im installing it right. Reading the documentation i found anaconda, is it right to first install anaconda and then try to install again with pip theano?. Is this the right way to install this library on MAC OS X?. How can i install this library correctly in order to use theano succesfully?
Installing Python with Homebrew and installing Theano with pip after that worked fine for me. I just needed to install nose after that to be able to run the tests.
brew install python
pip install Theano
pip install nose
I cannot help much installing the framework with Anaconda though.
Anaconda is indeed highly recommended for python libraries. In fact, Anaconda is not only for python in contrast to pip. You can read more here: What is the difference between pip and conda?
For installing Theano, I had already installed Anaconda. I just simply did:
conda install theano
Then, in Ipython, I successfully imported theano:
import theano
Consider installing Theano in a virtual enviroment as oppose to installing it globally via sudo. The significance of this step is nicely described here.
In your terminal window, do the following:
virtualenv --system-site-packages -p python2.7 theano-env
source theano-env/bin/activate
pip install -r https://raw.githubusercontent.com/Lasagne/Lasagne/v0.1/requirements.txt